hey,
it's me again, i need help with creating a header file for some functions so that i can use the functions in some other programs....
for example a header file that will include the function prototypes that i can access... I need the syntax for it.....:)

Recommended Answers

All 3 Replies

// yourheader.h
#ifndef _a_yourheader_included_
#define _yourheader_h_included_
class A
{
   B m_b;
   C *m_c;
   D *m_d;
  
public:
  void SetC(C *c);
  C *GetC() const;
  
  void ModifyD(D *d);
};
#endif

/************************************/

// yourcpp.cpp
void A::SetC(C* c)
{
  m_c = c;
}

C* A::GetC() const
{
  return m_c;
}

void A::ModifyD(D* d)
{
  d->SetX(0);
  d->SetY(0);
  m_d = d;
}
// yourheader.h
#ifndef _a_yourheader_included_
#define _yourheader_h_included_
class A
{
   B m_b;
   C *m_c;
   D *m_d;
 
public:
  void SetC(C *c);
  C *GetC() const;
 
  void ModifyD(D *d);
};
#endif
 
/************************************/
 
// yourcpp.cpp
void A::SetC(C* c)
{
  m_c = c;
}
 
C* A::GetC() const
{
  return m_c;
}
 
void A::ModifyD(D* d)
{
  d->SetX(0);
  d->SetY(0);
  m_d = d;
}

thanks,
but i dont think this code is meant for me.... what i expected was an deader file that contains a set of function prototypes... like a class' interface.... all i need is the declaration syntax for example

(declaration)header file name{
function 1;
function 2;
function 3;
}

so that when i want to use them i can just use the code

#include "header file name"

do you understand?

the syntax i will use:)

// header_file.h
#ifndef header_file
#define header_file

void function1();
void function2();

#endif

//////

// function_file.cpp
#include "header_file.h"

void function1() {

   // ....
}

//////

// main.cpp

#include "header_file.h"

int main() {

    function1();
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.