2
Contributors
3
Replies
45
Views
4 Years
Discussion Span
Last Post by phorce
0

Please could you include an example to your problem? It's kind of hard to find out where you are going wrong, but, here is an example (of what I assume you are trying to do):

// Test.h 

class Test {

    public: 

      Test(); // constructor 

      void doSomethingCreative();

};

And then your implementation of this class:

#include "Test.h" // assuming the header file is called "Test.h"

Test::Test()
{
   // constructor implementation
}

void Test::doSomethingCreative()
{
    // Method implemenation
}

At compile time, we just need to compile the .cpp file over the .h So, therefore your main will look something like so:

#include <iostream>
#include "Test.h"

int main(int argc, char *argv[]) {

   Test t;

   t.doSomethingCreative();
}

To compile, again, using GCC would be something like:

g++ Test.cpp main.cpp -o main
./main

Hope this helps slightly.

0

U are awesome man! Thanks, u've done it all. +u solved a little problem i had with oop c++

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.