У меня простой вопрос:
Вот базовый класс:
class CBox
{
public:
double m_Length;
double m_Width;
double m_Height;
CBox()
{
}
CBox(double lv=1.0,double wv=1.0,double hv=1.0)
:m_Length(lv),m_Width(wv),m_Height(hv)
{
}
~CBox();
protected:
private:
};
А вот и производный класс:
#ifndef CCANDYBOX_H
#define CCANDYBOX_H
#include "CBox.h"
#include <iostream>
#include <cstring>
class CCandyBox :CBox
{
public:
char* m_Contents;
CCandyBox(double lv, double mv, double hv, char* str):CBox(lv,mv,hv)
{
m_Contents = new char[ strlen(str) +1 ];
for(unsigned int i=0; i< strlen(str)+1; i++)
{ *(m_Contents+i) = *(str +i);
{
*(m_Contents+i) = *(str+i);
}
}
CCandyBox(char* str = "Candy"):CBox()
{
m_Contents = new char[ strlen(str) +1];
for(unsigned int i=0; i<strlen(str)+1;++i)
{
*(m_Contents +i) = *(str+i);
}
}
virtual ~CCandyBox()
{
delete[] m_Contents;
}
CCandyBox(const CCandyBox& other);
CCandyBox& operator=(const CCandyBox& other);
protected:
private:
};
#endif // CCANDYBOX_H
Функция Main.cpp просто включает в себя «CCandyBox.h» и простой «helloworld»
И выдает следующие ошибки:
C:\Work\Check\main.cpp|4|error: expected nested-name-specifier before 'namespace'|
C:\Work\Check\main.cpp|4|error: expected unqualified-id before 'namespace'|
C:\Work\Check\main.cpp|4|error: expected ';' before 'namespace'|
C:\Work\Check\main.cpp|4|error: expected unqualified-id before 'namespace'|
C:\Work\Check\main.cpp|11|error: expected '}' at end of input|
C:\Work\Check\CCandyBox.h||In constructor 'CCandyBox::CCandyBox(double, double, double, char*)':|
C:\Work\Check\CCandyBox.h|24|error: expected primary-expression before '(' token|
C:\Work\Check\CCandyBox.h|24|error: expected primary-expression before 'char'|
C:\Work\Check\CCandyBox.h|24|error: expected ';' before ':' token|
C:\Work\Check\CCandyBox.h|41|error: expected '}' at end of input|
C:\Work\Check\main.cpp||In member function 'int CCandyBox::main()':|
C:\Work\Check\main.cpp|9|error: 'cout' was not declared in this scope|
C:\Work\Check\main.cpp|9|note: suggested alternative:|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\iostream|62|note: 'std::cout'|
C:\Work\Check\main.cpp|9|error: 'endl' was not declared in this scope|
C:\Work\Check\main.cpp|9|note: suggested alternative:|
c:\mingw\bin\..\lib\gcc\mingw32\4.6.1\include\c++\ostream|543|note: 'std::endl'|
C:\Work\Check\main.cpp|11|error: expected unqualified-id at end of input|
||=== Build finished: 16 errors, 0 warnings ===|
Я использую MinGW с CodeBlocks. Помощь оценена