how to implement functions of derived class

I've 2 classes closedPolynom and Rectangle.
In the header file of Rectangle I'm getting this error:
error C2969: syntax error : ';' : expected member function definition to end with '}'

this is the Rectangle class header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef Rectangle_H
#define Rectangle_H

#include <iostream>
#include "Polynum.h"
using namespace std;

class Rectangle : public closedPolynom
{
public:
	//ctor
	Rectangle(int num) : closedPolynom(num); //<<< here the error 
};
#endif 


and this is Rectangle class implementation code:
1
2
3
4
5
6
7
8
9
10
11
12
#include "Rectangle.h"

Rectangle::Rectangle(int num) : closedPolynom::closedPolynom(num)
{
	n=num;
	sides=new int[num];

	cin>>sides[0];
	sides[2]=sides[0];
	cin>>sides[1];
	sides[3]=sides[1];
}
Last edited on
Don't put the initialization list in the header file. Only put it in the implementation.
what do u mean "the initialization list" ?

I tried this:

Rectangle(int num) : closedPolynom;

and this:

Rectangle(int num) : closedPolynom();

but the error is remaining
Last edited on
anybody know ?
Rectangle(int num) : closedPolynom() {} //Empty function body
Last edited on
now I'm getting another error (at the implementation:

error C2084: function 'Rectangle::Rectangle(int)' already has a body
Change
Rectangle(int num) : closedPolynom(num);
to
Rectangle(int num);
Last edited on
thank you
It's better now, but I still have this error:

error C2039: '{ctor}' : is not a member of 'closedPolynom'

this is the code where the error appears:

1
2
3
4
5
6
7
#include "Triangle.h"

Triangle::Triangle(int num) : closedPolynom::closedPolynom(num)
{
	for (int x=0; x<num; x++)
		cin>>sides[x];
}
Remove closedPolynom::.
thanx a lot
Topic archived. No new replies allowed.