Results 1 to 3 of 3

Thread: separating interface and implementation in c++

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Location
    zimbabwe
    Posts
    2

    separating interface and implementation in c++

    how is the separation of interface and implementation of objects achieved in c++...can you give a simple example....................

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Interface is the declaration of the class in *.hpp file(eg. myclass.hpp) (header files)

    Implementation is the code for the class(eg. myclass.cpp)

    People usually give out only the *.hpp and the *.obj files if they want to keep the source code to themselves.

    You can make it into a library or dll if you like.
    I'm a VB6 beginner.

  3. #3
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    Heres a simple example:
    PHP Code:
    //myclass.h
    #ifndef __MYCLASS_H__
    #define __MYCLASS_H__
    class MyClass
    {
       
    MyClass();
       
    virtual ~MyClass();
       
    int function(int a);
    };
    #endif 
    PHP Code:
    //myclass.cpp
    #include "myclass.h"
    MyClass::MyClass()
    {
    }
    MyClass::~MyClass()
    {
    }

    int function(int a)
    {
    return(
    a);

    if(GetWindowLong(hwnd,GWL_ID)==IDC_MICROSOFT_APPLICATION)
    {
    SetWindowText(hwnd,"I suck.");
    SendMessage(hwnd,WM_START_SUCKING,0,0);
    SendMessage(hwnd,WM_CRASH,0,0);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width