確かに、C ++で書き換えられた同じコードとテストケースがあります。

`` cpp
#include <iostream>
#include <cmath>
#include <vector>

2倍の距離（std :: vector <double> vector1、std :: vector <double> vector 2）{
    //両方のベクトルが同じ次元を持っているかどうかを確認します
    if（vector1.size（）！= vector2.size（））{
        nullを返します。
    }

    //ベクターの各要素間の二乗違いの合計を計算します
    double sum_of_squares = 0.0;
    for（int i = 0; i <vector1.size（）; i ++）{
        二重差= vector1 [i] -vector2 [i];
        sum_of_squares += std :: pow（difference、2）;
    }

    //四角の違いの合計の平方根を返します
    return std :: sqrt（sum_of_squares）;
}

int main（）{
    //テストケースa
    std :: vector <double> vector1a = {1、2、3};
    std :: vector <double> vector2a = {4、5、6};

    double distance_between_vectors = distance（vector1a、vector2a）;
    std :: cout << distance_between_vectors << std :: endl;//出力：5.196152422706632

    //テストケースb
    std :: vector <double> vector1b = {1、2、3};
    std :: vector <double> vector2b = {4、5};

    double distance_between_vectors = distance（vector1a、vector2a）;
    std :: cout << distance_between_vectors << std :: endl;//出力：null
}
`` `
Sure, here's the same code and test cases rewritten in C++:

```cpp
#include <iostream>
#include <cmath>
#include <vector>

double distance(std::vector<double> vector1, std::vector<double> vector 2) {
    // Check if both vectors have the same dimension
    if (vector1.size() != vector2.size()) {
        return NULL;
    }

    // Calculate the sum of squared differences between each element in the vectors
    double sum_of_squares = 0.0;
    for (int i = 0; i < vector1.size(); i++) {
        double difference = vector1[i] - vector2[i];
        sum_of_squares += std::pow(difference, 2);
    }

    // Return the square root of the sum of squared differences
    return std::sqrt(sum_of_squares);
}

int main() {
    // Test case A
    std::vector<double> vector1a = {1, 2, 3};
    std::vector<double> vector2a = {4, 5, 6};

    double distance_between_vectors = distance(vector1a, vector2a);
    std::cout << distance_between_vectors << std::endl; // Output: 5.196152422706632

    // Test case B
    std::vector<double> vector1b = {1, 2, 3};
    std::vector<double> vector2b = {4, 5};

    double distance_between_vectors = distance(vector1a, vector2a);
    std::cout << distance_between_vectors << std::endl; // Output: NULL
}
```