Hello! I have this code (I put just a part of it):
1 2 3 4 5 6 7 8 9
class TMTrackAnalyzer : public edm::EDAnalyzer {
public:
# declare public stuff here
private:
# declare private stuff here
for(int i=1;i<=10;i++){
cout<<i;
}
};
And I get this error:
expected unqualified-id before 'for'
for(int i=1;i<=10;i++){
But in that for loop I want to declare some private members of the class
If you declare variables within the loop, they're not private members of the class. They're local to the scope of the loop. Given the code kbw posted, you have four different places you can declare variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
class TMTrackAnalyzer : public edm::EDAnalyzer
{
public:
// 1. Declare public stuff here
private:
// 2. Declare private stuff here
void f()
{ // 3. Declare variables local to f() here
for (int i=1; i<=10; i++)
{ // 4. Declare variables local to the scope of the loop here
cout<<i;
}
}
};
Where do I need to call that method later?
Where ever you want to output the numbers 1-10, which is what f() does.
I don't understand you
¿what's the purpose of the loop?
> map< ObjectType, TH1F*> hisNumInputStubs_[tn];
first, that's an array declaration, so the brackets would set the size of the array.
but `tn' is an string, not a number.
If you wanted to populate the map (with value nullptr), there should be no type before.
However, the key of your map is an `Objectype', not a string.