i have a following code:

#include <vector>
using namespace std;

class A {
     int t;
     int f;
     public:
         A(){};
};

class B {
      vector <A> a(10);
      int y;
      public:
        B(){};
};
int main(int a, char *b[])
{
   B c;

}

when I try to compile Iam getting the error as ...


r.cc:12: error: expected identifier before numeric constant
r.cc:12: error: expected â,â or â...â before numeric constant


Note: no error if I declare the same vector in the main function.

You (and me ;)) can't define member constructor parameters in the member declaration. Right solution:

class B {      
  vector <A> a;
  int y;
public:
  B():a(10) {}
};

Apropos, erase semicolons after inline constructor definitions.
>any idea...
Read the language specifications more carefully ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.