Cześć
Mam problem z zadaniem w C++. Mam podzielić program na plik nagłówkowy i modułowy, plik nagłowkowy to nie problem natomiast coś jest nie tak z plikem z modułami (otrzymuje blad
Build: Debug in spr3 (compiler: GNU GCC Compiler) ===|
error: expected initializer before '::' token.
Kod:
Main.cpp
#include <iostream>
#include "naglowek.h"
using namespace std;
int main()
{
cout <<"Witaj!" << endl;
Punkt1 punkt1;
Punkt2 punkt2;
return 0;
}
Naglowek.h
#include <algorithm>
#include <string>
using namespace std;
class Punkt1
{
int p1;
int p2;
void wyswietl();
public:
Punkt1();
};
Punkt1::Punkt1()
{
cout << " Domyslne wspolrzedne punktu to:" << endl;
cout << p1 <<endl;
cout << p2 << endl;
p1 = 5;
p2 = 4;
cout <<"Wspolrzedne ustalone to: " <<endl;
void wyswietl();
}
//postac 2/////////////////////////////////////////////////////////
class Punkt2
{
int p1;
int p2;
public:
Punkt2();
};
Punkt2::Punkt2()
: p1 (2),
p2 (4)
{
cout <<"Wspolrzedne ustalone w drugim konstruktorze to: " <<endl;
cout << p1 <<endl;
cout << p2 << endl;
}
moduly.cpp
#include <iostream>
#include "naglowek.h"
using namespace std;
void Punkt1()::wyswietl()
{
cout << p1 <<endl;
cout << p2 << endl;
}
Czy ktoś podpowie co jest nie tak ?