Click here to Skip to main content
16,005,552 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Another group of questions... Pin
SilverShalkin28-Mar-02 15:26
SilverShalkin28-Mar-02 15:26 
GeneralRe: Another group of questions... Pin
Christian Graus28-Mar-02 16:13
protectorChristian Graus28-Mar-02 16:13 
Generalglobals Pin
Nish Nishant28-Mar-02 15:01
sitebuilderNish Nishant28-Mar-02 15:01 
GeneralRe: globals Pin
SilverShalkin28-Mar-02 15:23
SilverShalkin28-Mar-02 15:23 
GeneralRe: globals Pin
Nish Nishant28-Mar-02 15:28
sitebuilderNish Nishant28-Mar-02 15:28 
GeneralRe: Another group of questions... Pin
Jon Sagara28-Mar-02 15:28
Jon Sagara28-Mar-02 15:28 
GeneralRe: Another group of questions... Pin
Jon Sagara28-Mar-02 15:32
Jon Sagara28-Mar-02 15:32 
GeneralRe: Another group of questions... Pin
Christian Graus28-Mar-02 16:11
protectorChristian Graus28-Mar-02 16:11 
SilverShalkin wrote:
Hex Dec Oct: What is the differance and why use them seperat from each other.

The difference is what base they use. We use decimal because we have 10 fingers, so it was natural in the evolution of math that we consider 10 to be the number that requires one more significant figure. Computers think in binary, which meshes nicely with base 8 (octal ) and base 16 (hex). I've never seen oct used for anything in particular.

The Windows calculator program can show you how the same number is displayed in the different bases, or look at my ostringstream article for a way to stream a number out as different bases. It works the same way if you're just streaming to cout.

SilverShalkin wrote:
Globals: How do you decalare a global inside of a little program?

Just by declaring it. Any variable declared outside of a class or function is global. When you're doing it in C++, the best way is to use extern, which tells the compiler a variable exists, but does not declare it. use extern int i in stdafx.h, and int i in stdafx.cpp to make a variable visible everywhere.

You would be foolish not to wrap such variables in a namespace, so that they have some protection from corruption. Even then, avoid globals if you can.

SilverShalkin wrote:
MFC - C++: Ive asked this question before... im going to build a game engine that would allow me to build 2D games that i would like to host over the internet... The engine i would like it to be all in windows, but what language or toolkit should i use? MFC or C++, what one would give me more flexibility and make the job allot less work than it already seems to be?

MFC is a library that you use in C++, you probably mean MFC or Win32. MFC will take a lot of work away because of the stuff it gives you for networking and so on, but I'd suggest Win32 with DirectX, because you'll need DX anyhow for DirectDraw, and it gives you the networking stuff as well, in DirectPlay.

SilverShalkin wrote:
Null: Ive seen the 'null' statement used all the time, but i dont know what it is used for. "i think this is a vary newbie question but you know

A pointer that does not point to a valid address should point ot 0. Calling delete on such a pointer will not do anything. NULL is a #define, it equates to (void*) 0.

SilverShalkin wrote:
Switch (break and continue): I understand the switch "I think" but im not to sure on break and continue commands... How do i use them?

You don't use continue in break statements. If you don't use a break in a switch, it falls through, like this:

int i = 0;

switch (x)

case 0:
i = 7;
default:
i = 10;

In this case i will always equal 10, because even the case 0 will fall through and the defaul will also execute.

contine and break are used in loops, break stops the loop and continue jumps to the next iteration, so the loop continues but any other code is not executed for this iteration only.

SilverShalkin wrote:
Delete: how do i use this? and what is the syntax?

If a variable is a pointer, then it vecomes an object when it is created with new, and the memory is deallocated and the destructor called when delete is called. You should also set this pointer to NULL.

int * p = new int;
*p = 7; // NOT p = 7, that sets the memory address, not the value )
// use p
delete p;
*p = 5; // ERROR - memory is deallocated
p = NULL;

SilverShalkin wrote:
Public: I looked this one up, but didnt understand. Public: its not a goto statment is it? (dont think so) why use this? also, there is a private: one, how do you use these and why?

In a class, you have functions and members. Anything that is public is visible by anyone who has an instance of a class. private is visible only to the class itself. Often variables are made private and exposed through methods that can validate the data being put into a variable. For exmaple if 0-100 is a valid range for a variable, the closest I can get is a char or unsigned char, but I need to validate the values coming in, or I could get values between -127 and 127, or 0 and 255.

SilverShalkin wrote:
return: Return like in the int main() and return 0; i understand, but... there is other things that you can do with the return statment that i dont quit get... can any one help?

All you can do is return a value. What don't you get ?

SilverShalkin wrote:
~#if and #define and #endif #else... : why is there a # sign on these? and the define, what does it do, or what is its purpose?

Because they are processed by the preprocessor. They can be used to create different versions ( such as debug and release ) or to create macros. The preprocessor uses them to decide what code is passed to the compiler.

SilverShalkin wrote:
~std::stream: What does this do?
~std::fstream: what does this one do, and what is its differance to the other one?
~if stream and stream: what do these do? "these last ones are just a (curiosity) and could probably help allot in the future.


Is there a std::stream ? Surely it's a base class. IOStreams are part of the standard library. A fstream is a bidirectional file stream, ofstreams and ifstreams also exist. Read my article on ostringstream - ofstream works the same way, and both work the same way as cin/cout.

SilverShalkin wrote:
Class: what is a class used for?

To encapsulate a block of logic. For exmaple, MFC has a CPoint class, it encapsulates the data and operations one might do on a point. I can create an instance of a CPoint and I can add them together, compare them, etc. It's a powerful tool to hide implimentation details from users of an object, and also simple to organise code.

SilverShalkin wrote:
Sound: I really desire to make a sound engine for my game, "and if not in my game" just somthing that would be fun to program and mess around with. But i dont know exactly where to start with the sound and how to send sound to the speakers. Can anyone help in this?

For games you should use DirectSound, so you can play more than one sound at the same time.


SilverShalkin wrote:
Well, thats all, "allot of questions like i said" but this is like a week of reading and toiling with out asking any at all " Some of the questions may be stupid and some maybe so lame or easy that maybe a quick syntax would help Sorry for the annoyance "to those who this annoys..."

Anyone who gets annoyed that you're trying to learn something is best ignored, not apologised to. The number of questions probably means I've given brief answers, but just ask if no-one here has yet clarified any of these points sufficiently.


Christian

The tragedy of cyberspace - that so much can travel so far, and yet mean so little.

"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
GeneralRe: Another group of questions... Pin
SilverShalkin28-Mar-02 17:30
SilverShalkin28-Mar-02 17:30 
GeneralRe: Another group of questions... Pin
alex.barylski28-Mar-02 19:39
alex.barylski28-Mar-02 19:39 
GeneralRe: Another group of questions... Pin
Nish Nishant28-Mar-02 20:55
sitebuilderNish Nishant28-Mar-02 20:55 
GeneralRe: Another group of questions... Pin
alex.barylski28-Mar-02 22:12
alex.barylski28-Mar-02 22:12 
GeneralRe: Another group of questions... Pin
Mazdak28-Mar-02 21:09
Mazdak28-Mar-02 21:09 
GeneralRe: Another group of questions... Pin
alex.barylski28-Mar-02 22:08
alex.barylski28-Mar-02 22:08 
QuestionIIsWebVirtualDir and using the Internet Information Services? Pin
Craig Miller28-Mar-02 12:48
Craig Miller28-Mar-02 12:48 
Generalbeginning a thread : MFC vs direct API Pin
28-Mar-02 11:36
suss28-Mar-02 11:36 
GeneralRe: beginning a thread : MFC vs direct API Pin
Tomasz Sowinski28-Mar-02 11:36
Tomasz Sowinski28-Mar-02 11:36 
GeneralRe: beginning a thread : MFC vs direct API Pin
28-Mar-02 12:06
suss28-Mar-02 12:06 
GeneralRe: beginning a thread : MFC vs direct API Pin
Tomasz Sowinski28-Mar-02 12:11
Tomasz Sowinski28-Mar-02 12:11 
GeneralRe: beginning a thread : MFC vs direct API Pin
Tim Smith28-Mar-02 12:19
Tim Smith28-Mar-02 12:19 
GeneralRe: beginning a thread : MFC vs direct API Pin
Tomasz Sowinski28-Mar-02 12:25
Tomasz Sowinski28-Mar-02 12:25 
GeneralRe: beginning a thread : MFC vs direct API Pin
Tim Smith28-Mar-02 12:30
Tim Smith28-Mar-02 12:30 
GeneralRe: beginning a thread : MFC vs direct API Pin
Nish Nishant28-Mar-02 14:44
sitebuilderNish Nishant28-Mar-02 14:44 
GeneralRe: beginning a thread : MFC vs direct API Pin
Tim Smith28-Mar-02 14:53
Tim Smith28-Mar-02 14:53 
GeneralRe: beginning a thread : MFC vs direct API Pin
29-Mar-02 7:04
suss29-Mar-02 7:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.