error: expected unqualified-id before ‘{’ token

I am getting this error when trying to implement methods for class MyClass1.

task1.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
#include <iostream>

#include "MyClass1.h"
#include "MyClass2.h"
#include <string.h>

using namespace std;



int main()
{
  MyClass1* test = new MyClass1();
}

MyClass1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef MYCLASS1_H
#define MYCLASS1_H
#include <iostream>
#include <string>
#include "MyClass2.h"
using namespace std;
class MyClass1
{
  private:
    MyClass2** myArr;
    int size;
  public:
    MyClass1() ;
    MyClass1(int n);
    MyClass1(int v1, int v2,int v3=0,int v4=0,int v5 =0);
    MyClass1(int* n ,int s);
    ~MyClass1();
    void printArray(int n);
    void addToArray(int* n,int s);
    void removeArray(int n);    
};
#endif 

MyClass1.h
1
2
3
4
5
6
#include "MyClass1.h"
using namespace std;
MyClass1::MyClass1
{
 cout<<"success";  
}


Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
task1: MyClass1.o task1.o MyClass2.o
	g++ -Werror task1.o MyClass1.o MyClass2.o -o task1

MyClass2.o: MyClass2.h MyClass2.C 
	g++ -Wall -c MyClass2.C -o MyClass2.o

MyClass1.o: MyClass1.h MyClass1.C 
	g++ -Wall -c MyClass1.C -o MyClass1.o
	
task1.o: task1.C
	g++ -Wall -c task1.C -o task1.o

clean:
	\rm *.o *~ ass

closed account (DSLq5Di1)
Missing some parentheses for your constructor definition.
Topic archived. No new replies allowed.