I listed my code below, but apparently the code does not like vector a[10]. What cause the problem and how to fix it.
/home/tbjc1magic/grive2/test1/build/G__test.cxx: In member function ‘virtual void test::Streamer(TBuffer&)’:
/home/tbjc1magic/grive2/test1/build/G__test.cxx:124:25: error: expected unqualified-id before ‘[’ token
vector[10] &R__stl = aa[R__l];
^
/home/tbjc1magic/grive2/test1/build/G__test.cxx:125:10: error: ‘R__stl’ was not declared in this scope
R__stl.clear();
^
/home/tbjc1magic/grive2/test1/build/G__test.cxx:142:25: error: expected unqualified-id before ‘[’ token
vector[10] &R__stl = aa[R__l];
^
/home/tbjc1magic/grive2/test1/build/G__test.cxx:143:23: error: ‘R__stl’ was not declared in this scope
int R__n=int(R__stl.size());
^
/home/tbjc1magic/grive2/test1/build/G__test.cxx:146:28: error: expected unqualified-id before ‘[’ token
vector[10]::iterator R__k;
^
/home/tbjc1magic/grive2/test1/build/G__test.cxx:147:18: error: ‘R__k’ was not declared in this scope
for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {
^
CMakeFiles/example.dir/build.make:97: recipe for target ‘CMakeFiles/example.dir/G__test.cxx.o’ failed
make[2]: *** [CMakeFiles/example.dir/G__test.cxx.o] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/example.dir/all’ failed
make[1]: *** [CMakeFiles/example.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2
///main.cxx
#include “TString.h”
#include
#include “test.h”
using namespace std;
int main()
{
test t;
return 1;
}
///test.h
#ifndef TEST
#define TEST
#include "TObject.h"
#include <vector>
#include "TString.h"
class test: public TObject {
public:
test();
std::vector<TString> aa[10];
private:
ClassDef(test, 1)
};
#endif
/// test.cxx
#include "test.h"
#include <iostream>
using namespace std;
ClassImp(test)
test::test()
{
cout<<"test:bobo"<<endl;
}
///CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(tbjcAnalysis)
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package(ROOT)
include(${ROOT_USE_FILE})
include_directories(${ROOT_INCLUDE_DIRS})
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
include_directories(${PROJECT_SOURCE_DIR})
ROOT_GENERATE_DICTIONARY(G__test test.h)
file(GLOB sources ${PROJECT_SOURCE_DIR}/*.cxx)
add_executable(example main.cxx G__test.cxx ${sources})
target_link_libraries(example ${ROOT_LIBRARIES})
main.cxx (115 Bytes)
test.cxx (119 Bytes)
test.h (200 Bytes)
CMakeLists.txt (478 Bytes)