Hello!
I want to split my program into several files.
I have created 3 files:
file1.h:
#ifndef _file1
#define _file1
#include <iostream>
#include <vector>
struct StructTest
{
double x;
double y;
StructTest(double x, double y);
};
std::vector<StructTest> initialize();
#endif // _file1
file1.cpp:
#include "file1.h"
StructTest::StructTest(double x, double y) : x(x), y(y)
{
}
std::vector<StructTest> initialize()
{
std::vector<StructTest> struct_test_vec_obj;
for (int i = 0; i < 10; i++)
{
struct_test_vec_obj.push_back(StructTest(i, i * 10));
}
return struct_test_vec_obj;
}
Source.cpp:
#include <iostream>
#include "file1.h"
using namespace std;
int main()
{
std::vector<StructTest> struct_test_vec_obj = initialize();
for (int i = 0; i < struct_test_vec_obj.size(); i++)
{
cout << "x = " << struct_test_vec_obj[i].x << "; y = " << struct_test_vec_obj[i].y << endl;
}
//system("pause");
return 0;
}
This code works in VS2013.
In order to compile this code in root I have added in rootlogon.c this code:
{
gROOT->ProcessLine(".L D:\\git_repositories\\Parser_signal_finder\\VS2013\\Parser\\Test\\file1.h");
gROOT->ProcessLine(".L D:\\git_repositories\\Parser_signal_finder\\VS2013\\Parser\\Test\\file1.cpp");
gROOT->ProcessLine(".L D:\\git_repositories\\Parser_signal_finder\\VS2013\\Parser\\Test\\Source.cpp");
}
I launch my code by the next command and have an error:
root -l
main()
Error: Can't take address for reference type value defalloc.h(130)
My version is
ROOT 5.34/36 (v5-34-36@v5-34-36, Apr 05 2016, 10:25:45 on win32)
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Could you help?
Thank you in advance.
Best regards, Vladislav.