[SOLVED] [C++] What is wrong with my constructor?
by dedec0 from LinuxQuestions.org on (#5DNXS)
Hello,
I am having a problem with a basic C++. I have searched around, but i only found reasons pretty different from what my code is. I have also reduced it to a minimal code that reproduces the error.
The gcc error message is:
Code:t.cpp:15:5: error: expected unqualified-id before {' tokenMy code uses 2 files. You can see a partial screenshot of them in Vim here:
https://images2.imgbox.com/3a/59/WhjTFCbD_o.png
Help the image service: https://imgbox.com/WhjTFCbD
Want to read and copy here? Fine. file t.cpp is:
Code:#include <iostream>
#include <cstdlib>
using namespace std;
#include "t.h"
class Agent
{
public:
enum e { a,b,c,d };
int z[16];
int n;
Agent
{
int i;
for( i=0; i<16; i++)
z[i] = 0;
}
};file t.h is:
Code:#ifndef tH
#define tH
#endifSo, what is wrong with my code? I tried to do a few changes with it, but this error never disappeared, except when something i know is wrong was written. What is missing or wrong in the class constructor? What is an "unqualified-id"?
Unrelated question: why i do not have gcc manual page, having Debian gcc installed?? I checked files installed with its package, and it has other man pages, but not of "gcc" itself. Years ago it had!


I am having a problem with a basic C++. I have searched around, but i only found reasons pretty different from what my code is. I have also reduced it to a minimal code that reproduces the error.
The gcc error message is:
Code:t.cpp:15:5: error: expected unqualified-id before {' tokenMy code uses 2 files. You can see a partial screenshot of them in Vim here:
https://images2.imgbox.com/3a/59/WhjTFCbD_o.png
Help the image service: https://imgbox.com/WhjTFCbD
Want to read and copy here? Fine. file t.cpp is:
Code:#include <iostream>
#include <cstdlib>
using namespace std;
#include "t.h"
class Agent
{
public:
enum e { a,b,c,d };
int z[16];
int n;
Agent
{
int i;
for( i=0; i<16; i++)
z[i] = 0;
}
};file t.h is:
Code:#ifndef tH
#define tH
#endifSo, what is wrong with my code? I tried to do a few changes with it, but this error never disappeared, except when something i know is wrong was written. What is missing or wrong in the class constructor? What is an "unqualified-id"?
Unrelated question: why i do not have gcc manual page, having Debian gcc installed?? I checked files installed with its package, and it has other man pages, but not of "gcc" itself. Years ago it had!