eclipse - How to use header functions in source file in C++? -
i'm new c++ programming language , different java. tried use functions header made when use function header , eclipse c++ ide says member declaration not found except constructor while found in header public.
car.h file (header) :
#include <string> using namespace std; class car { private : string name; string model; int year; int width; int height; int depth; public : car (); car (string n, string m, int y, int w, int h, int d); void setname(string n); void setmodel (string m); void setyear (int y); void setsize (int w, int h, int d); string getname (); string getmodel(); int getyear(); int getwidth(); int getheight(); int getdepth(); };
car.cpp file (source)
#include <iostream> #include <string> #include "car.h" using namespace std; car::car(string n, string m, int y, int w, int h, int d) { //works name = n; model = m; year = y; width = w; height = h; depth = d; } car::getname() { // ide says member declaration not found return name; } car::getmodel() { // ide says member declaration not found return model; } car::getyear() { // ide says member declaration not found return year; } car::getwidth() { // ide says member declaration not found return width; } car::getheight () { // ide says member declaration not found return height; }
what have did wrong ?
all of functions missing return type, example
string car::getname() { return name; }
Comments
Post a Comment