You remind me of the old times.
I put in fur.
You remind me of the old times.
I put in fur.
that her very
Beginning of the new end, the dawn of destruction.
Symphony of destruction - Megadeth
British chavs with a million, returning babies ate the cake while FEEDING a starving county.
But the OP did this. Reread the code; there's nothing wrong with the way he/she implemented preprocessor directives.
....albeit, in a wrong way.
When you write guards like that to prevent recursive inclusion, you need to specify the Header file name in the preprocessor directives and not the class name. The OP has used the class name (Ship_State) instead of the header file name (w.h).
No, for both.
If you need a less complicated way, the only thing you can do is follow the code example and make one for your needs.
And since Registry is windows specific, you need to use W32 API to access the registry. There is no portable or easy way out, as far as my knowledge goes.
The way you are trying to incorporate the wrong concept of const variables in your program is causing all the problems.
If you declare a variable as const, you need to specify the const qualifier before the dataype, like this:
const int SIZE = 10 ; // you must specify the value
Since const variables can't be modified (alteast not using the same name) you need to specify an initial value for the variable the way I have done above. Also since initialization of non static members inside a class is not allowed in C++, so you have to make those variables static.
static const double dt=1.0 ;
static const double gravity=0.5 ;
static const double engine_strength = 1.0 ;
static const double safe_velocity = -0.5 ;
static const char burn_key = 'b';
You could also create a seperate header file with the constants and include it whenever you need to use the values.
You need to tell the compiler that the class you are using exists. You do this by something known as forward declarations.
// Enemy.h
#ifndef ENEMY_H
#define ENEMY_H
class Player ; // forward declaration
class Enemy
{
int c ;
int d ;
public:
int get (Player a) ; // now this works
} ;
#endif
// Player.h
#ifndef PLAYER_H
#define PLAYER_H
class Enemy ; // forward declaration
class Player
{
int a ;
int b ;
public :
int get (Enemy a) ; // now this works
} ;
#endif
// Driver.cpp
#include "a.h"
#include "b.h"
int main()
{
Enemy e ;
Player p ;
return 0;
}
Not to forget that his scheme will work only for characters whose count is less than or equal to 9. Any higher and the algo is busted.
@OP Maybe you should try out [search]sprintf[/search] instead of adding plain ascii characters.
all over the
No I wasn't asking, I was correcting. :cheesy:
;)
Well, doing that would be really simple. Posting the entire solution would be like wasting the efforts Narue and the others have put in solving the OP's problem.
I would leave the OP to figure out this one for himself.
How does your version sort the words of same occurrence into alphabetical order though. I can't see it?
Oh, I guess I overlooked that requirement. Here is the fix:
static int wordOccurrenceSort(const void *p1, const void *p2)
{
struct crap *sp1 = (struct crap *) p1;
struct crap *sp2 = (struct crap *) p2;
if (sp1->wordOccurrence == sp2->wordOccurrence)
return strcmp (sp1->word, sp2->word) ;
else
return (sp1->wordOccurrence - sp2->wordOccurrence) ;
}
static int wordOccurrenceSort(const void *p1, const void *p2) { struct crap *sp1 = (struct crap *) p1; struct crap *sp2 = (struct crap *) p2; if (sp2->wordOccurrence > sp1->wordOccurrence ) { return 1; //not sure what value to assign? } if (sp2->wordOccurrence < sp1->wordOccurrence ) { return 0;//not sure what value to assign? } if ( sp2->wordOccurrence == sp1->wordOccurrence) { int order = strcmp(sp1->word,sp2->word); return order; //not sure what value to assign? } }
You could simply have done something like this since this function is required to return how one element is placed wrt another and not any absolute value. Only the sign matters here (+ve, -ve, zero).
static int wordOccurrenceSort(const void *p1, const void *p2)
{
struct crap *sp1 = (struct crap *) p1;
struct crap *sp2 = (struct crap *) p2;
return (sp1->wordOccurrence - sp2->wordOccurrence) ;
}
You get attend their concert.
I put in some grass.
so can you explain how this variable declaration works when it get repeated.
y won't u get the error the redefinition of var x?
Think of this as declaring a variable in the naked block, whose scope and lifetime is limited to the block in which it is declared.
int g_myVariable = 100 ; // global scope and lifetime
int main (void)
{
int main_myVariable = 100 ; // local to the function main
for ( int i = 0; i < 10; ++i ) // scope of i is the entire loop block
{
int j = 0 ; // j is destroyed after each iteration and a new
// one is created at the start of every iteration
}
}
all Daniweb members
Broken Home - Papa Roach
heaven - demons
kind of trouble
Toes count in our body should be two for us to pass out as normal humans.
French SOLDIERS and a fleet of battleships followed commands while incarcerating a hostile daffodil.
You are getting an error because you are trying to print the "input stream" and not the "character array". In your use of fgets ( ) , "input" is the stream from which you are reading, line by line.
char buffer [BUFSIZ] = { '\0' } ;
while ( fgets (buffer, BUFSIZ, file_stream) != NULL )
{
// process the line keeping in mind that it
// has a newline at its end
printf ("%s", buffer) ;
}
Hate to feel - Alice in Chains
You get a unique breed of dog.
I put in karma.
leak
can do better.
Brave berserkers and a FLEET of tanks followed soldiers while capturing a hostile country.
rule the world.
I stand alone - Godsmack
skin -> shed
Results of nuclear warfare are so very obvious. Extinction of human race...
leet
Being a honest person, I hand it back to you so that it isn't misused.
I put in a mongrel.
s.o.s, Ancient Dragon; thank you for the advice.
You are welcome. Oh and btw, best of luck with your project...
Arrangement for parties has to be done well in advance.
Python -> Boa
YOu get some ninjas holding it.
I put in a light bulb.
creep
Only then can
Falling away from me - Korn
Come to think
Brave cavaliers and a mass of TANKS followed soldiers while capturing a hostile country.
Brave cavaliers and an MASS of ghosts followed soldiers while capturing a renowned country.
Products and consumers have a never ending relationship.
As far as virtual functions are concerned, they definately incur some performance overhead, but in normal senarios, the cost and nightmares of maintaining repeatitive code is far more than that when virtual functions are used.
The most important point you have to consider while using virtuals is that the binding is done at runtime as compared to when the code is repeated, in which case the binding is compile time.
Also a very important thing which mars the performance of virtual functions is that they can't be inlined. So if you are repeatedly calling chunks of code with the virtual tag attached, you suffer a great performance hit.
Then again, it boils down to what kind of design you have used in your project, but still the cost of setting up vptr's and not having the ability to inline has to be taken in consideration.
amber -> ruby