Problem z skompilowaniem ćwiczenia.
Napisane: sobota, 19 stycznia 2013, 23:18
Witam! Chciałbym się zwrócić do Was z prośbą o rozwiązanie problemu, który napotkałem przy ćwiczeniu z videokursu c++ lekcji 39 "Konstruktor kopiujący". Oto co mi wyskakuje:
In file included from main.cpp
Error return type specification for constructor invalid
G:\c++ byle jakie aplikacje\Makefile.win [Error] [main.o] Error 1 (if this is the only error: please check your library includes)
A oto kod:
plik main:
plik punkt2d.h
plik punkt2d.cpp
In file included from main.cpp
Error return type specification for constructor invalid
G:\c++ byle jakie aplikacje\Makefile.win [Error] [main.o] Error 1 (if this is the only error: please check your library includes)
A oto kod:
plik main:
Code: Zaznacz cały
#include <iostream>
#include "punkt2d.h"
using namespace std;
int main(int argc, char *argv[])
{
Punkt2d a(10, 20);
Punkt2d b(10, 20);
if(a == b)
{
cout << "Program jest napisany poprawnie! ;-)" << endl;
}
else
{
cout << "Blad!" << endl;
}
return 0;
}
Code: Zaznacz cały
class Punkt2d
{
int x;
int y;
int suma;
public:
Punkt2d() { };
int Punkt2d(int, int);
int getX();
int getY();
int operator==(Punkt2d);
};
Code: Zaznacz cały
#include "punkt2d.h"
Punkt2d::Punkt2d(int x, int y)
{
this->x = x;
this->y = y;
}
int Punkt2d::getX()
{
return this->x;
}
int Punkt2d::getY()
{
return this->y;
}
int Punkt2d::operator==(Punkt2d cos)
{
this->suma == this-> x; this-> y;
return this->suma;
}