Quick question on using the constructer with multiple files.
Posted
by sil3nt
on Stack Overflow
See other posts from Stack Overflow
or by sil3nt
Published on 2010-04-15T05:25:27Z
Indexed on
2010/04/15
5:33 UTC
Read the original article
Hit count: 372
Hi there, I have this class header
//header for class.
#ifndef Container_H
#define Container_H
#include <iostream>
using namespace std;
const int DEFAULT=32;
class Container{
public:
Container(int maxCapacity = DEFAULT);
~Container();
void insert(int item, int index);
void erase(int index);
int size()const;
private:
int sizeC;
int capacityC;
int * elements;
};
void info();
#endif
and this source file
#include "container.h"
Container::Container(int maxCapacity = DEFAULT){
int y;
}
void Container::insert(int item, int index){
int x;
}
and when i compile this i get the following error message
test.cpp:4: error: default argument given for parameter 1 of `Container::Container(int)'
container.h:12: error: after previous specification in `Container::Container(int)
what have i done wrong here?
© Stack Overflow or respective owner