In a windows MSVC6.0 compiler, if there is a workspace with one project in it, what files would be in the Header Files folder and what files would be in the External Dependencies folder?
I thought those files which are explicitly included (#include <*.h> are to be in the Header Files folder and thsoe which are in turn included by add...
game.h needs:
- packet.h
- socket.h
server.h needs:
- socket.h
socket.h needs:
- game.h
The problem comes when I try to include socket.h into game.h, because socket.h has game.h included already. How do I solve these kind of problems?
...
Why do we need both using namespace and include directives in C++ programs ?
For example,
#include <iostream>
using namespace std;
int main() {
cout << "Hello world";
}
Why is it not enough to just have #include or just have "using namespace std"
and get rid of the other ?
(I am think of an analogy with Java, import java.net.* ...
I have the following doubts on header files usage.
1 - Include guards placing after comments
/* Copyright Note and licence information (multiple lines) */
#ifndef FOO_H
#define FOO_H
// Header file contents
#endif
Herb Sutter says in his "C++ coding standards" book that code like the above is problematic. He is saying the "#ifndef" s...
I have a class which has many small functons. By small functions, I mean functions that doesn't do any processing but just return a literal value. Something like
string Foo::method() const{
return "A";
}
I have created a header file "Foo.h" and source file "Foo.cpp". But since the function is very small, I am thinking about puttin...
Hi.
Basically I want to know if it is possible to implement a C++ header from a C# interface, because I can't make it work.
Example:
C# Interface:
public interface A { void M( ushort u ); }
C++ header:
public ref class B : A { void M( unsigned short u ); }
Returns "Error C3766".
Thanks in advance.
...
Background
I have an abstract class, something like
class IConverter{
public:
virtual void DoConvertion() = 0;
};
There will be many concrete classes which just implements DoConvertion method.
class TextConverter : public IConverter{
public:
virtual void DoConvertion(){
// my code goes here
}
};
class ...
I'm a C Newb
I write lots of code in dynamic languages (javascript, python, haskell, etc.), but I'm now learning C for graduate school and I have no idea what I'm doing.
The Problem
Originally I was building all my source in one directory using a makefile, which has worked rather well. However, my project is growing and I would like ...
if I create
typedef double (MyClass::*MemFuncGetter)();
in a header file, do I need to include "MyClass.h" or would forward declaring suffice?
Header file:
#ifndef _TEST_
#define _TEST_
#include "MyClass.h" //do I need this?
//or I can just say class MyClass;
typedef double (MyClass::*MemFuncGetter)();
#endif
What are the li...
Is using .h as a header for a c++ file wrong?
I see it all over the place, especially with code written in the "C style".
I noticed that Emacs always selects C highlighting style for a .h header, but c++ for hpp or hh.
Is it actually "wrong" to label your headers .h or is it just something which annoys me?
EDIT:
There is a good (is...
Good evening :)
I'm playing around with g++ and makefiles. I've gotten to this point:
foo.h:
#ifndef _FOO_H_
#define _FOO_H_
#include "bar.h"
class foo {
private:
bar something;
public:
bool start();
bool stop();
};
#endif // _FOO_H_
Foo.h is eventually included in my main cpp file so I can set things in motion by cal...
I have a plain C code with *.c and *.h files in the workspace.
I have a header file 1.h declaring some structure as
struct my1
{
int a;
..
..
}my_t;
But when i try to declare a variable of type struct my1 in another header file 2.h as follows:-
struct my1 variable1;
It gives error at this declaration point.
Looks like my1 is und...
Many languages, such as Java, C#, do not separate declaration from implementation. C# has a concept of partial class, but implementation and declaration still remain in the same file.
Why doesn't C++ have the same model? Is it more practical to have header files?
I am referring to current and upcoming versions of C++ standard.
...
This may seem like a really stupid question, but what is the cost of including (actually, calling #import) a header file in Objective-C? I get tired of constantly including the same headers in various locations, so I decided to simply create a GlobalReferences.h file that includes several commonly-referenced headers.
Is there any apprec...
I initialized a vector of pointers called "antiviral_data", and am able to use antiviral_data.push_back without problems. But when I try to do the same thing with "viral_data" I get an error, because the compiler thinks I am redeclaring "viral_data":
vector<virus*> viral_data;
vector<virus*>::iterator vI;
viral_data.push_back(new X1(9, ...
I find that if there are a lot of classes the compilation time is dramatically increased when I use one *.h and one *.cpp file per class. I already use precompiled headers and incremental linking, but still the compile time is very long (yes I use boost ;)
So I came up with the following trick:
defined *.cpp files as non-compilable
de...
I'm playing around with Box2D for fun right now, and after getting the hang of some of the concepts I decided to make my own test for the test bed (Box2D comes with a set of examples and has a simple extendable Test class for making your own tests). I started by grabbing one of the other tests, ripping out everything but the function sig...
I've worked with a number of C projects during my programming career and the header file structures usually fall into one of these two patterns:
One header file containing all function prototypes
One .h file for each .c file, containing prototypes for the functions defined in that module only.
The advantages of option 2 are obvious t...
Hi,
I have a header file in which there is a large struct. I need to read this structure using some program and make some operations on each member of the structure and write them back.
For example I have some structure like
const BYTE Some_Idx[] = {
4,7,10,15,17,19,24,29,
31,32,35,45,49,51,52,54,
55,58,60,64,65,66,67,69,
70,72,76,7...
When i first learned c++, I had already coded in many other languages prior to it, which made the prospect of headers really depressing. So far, my solution to coding without header files in c++ has been far from optimal, limiting what I can do in the language.
Is there any way to not have to write function declarations twice (headers) ...