0

Hi.

Can you explain to me on how to "inherit" (if that's the right word) stuff from a header file, and on how to write one? (A header file)

Like if i wrote this;

class Foo {

int a = 123;

}

in a header, how would i call it?

For example, how would i do this:

Foo(); //Calls the Foo class

Using classes was just an example.

3
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by pseudorandom21
0

You would have to include that header before you can use it. For example,

//in foo.h
struct Foo{
 //...
};
//main.cpp
#include <iostream>
#include "foo.h"
int main(){
 Foo f;
}
0

Ah, crap. Did not get it to work, sorry.

Here is my error:

IntelliSense: PCH warning: cannot find a suitable header stop location. An intellisense PCH file was not generated.

And "my" code is just the "struct foo"

Edited by axeves: n/a

0

Precompiled Header error?

Try adding the class to the pre-compiled header file.

Also you have to have include guards.

Typically for multi-platform you'll want:

#ifndef SOMEHEADER_H
#define SOMEHEADER_H

struct foo{
   int x,y;
};

#endif
This topic has been dead for over six months. 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.