"mark" <anthonymor...@...> wrote:
>
> Mark.h
>
> #pragma once //i am using visual c++ 2008 compiler/ide,
> this is equvilaent to #ifndef mark_h... etc...
Not exactly equivalent, but I won't dwell on that.
> #include <string> //is this part needed here?
Do you use strings? If so, you'll need the string header.
> class MyClass
> {
> public:
> int id;
> MyClass(int);
Why not make the constructor inline?
> ~MyClass(){}
> string func() // i want this function to return the
> string below, but it doesnt
Try std::string
> {
> return "6767";
> }
>
> };
> --------------------------------------------------------------------
> Mark.cpp
> #include "Mark.h"
>
> MyClass::MyClass(int id)
> {
> this->id = id;
> }
You should use the explicit contructor syntax, even for POD
members...
MyClass::MyClass(int i) : id(i) { }
> ---------------------------------------------------------------------
> Main.cpp
>
> #include "Mark.h"
> #include <iostream>
> using namespace std;
>
> int main()
> {
> MyClass M(299);
> cout << M.func() <<endl;
> return 0;
> }
>
> ive got 8 errors.
They almost certainly stem from the missing std:: in your header.
--
Peter