|
-
Jan 29th, 2002, 03:21 PM
#1
Thread Starter
Frenzied Member
C++ and Visual C++
what is the difference between C++ and Visual C++...i heard it's like the difference between Qbasic and Visual Basic....almost.
-
Jan 29th, 2002, 04:29 PM
#2
Member
Visual C++ is a programming environment and compiler, but C++ is a language. You can use C++ in other compliers besides Microsoft's (Borland's, Dev-Cpp, etc.). You pay for (or steal) Visual C++, but C++ is always free. Visual C++ also adds MFC to make things easier and defines some other Microsoft specific things. You can think of Visual C++ as the program that helps you write and edit C++ code.
-
Jan 29th, 2002, 04:42 PM
#3
Thread Starter
Frenzied Member
what is a MFC, i dont think i've ever heard of that.
also i am new to C++ all i can do is stuff like:
Code:
#include "iostream.h"
void main()
{
cout << "Pick a number: ";
int number;
cin >> number;
cout << "Your number was: " << number;
}
Last edited by SomethinCool; Jan 29th, 2002 at 04:46 PM.
-
Jan 29th, 2002, 05:02 PM
#4
Member
MFC stands for Microsoft Foundation Classes. They are used to make it easier to work with windows, and controls - much like Visual Basic. If you are a beginner with C++ you should probably not use them right away - learn the API first. Other users on this board will agree that it is better to learn how to create programs with the plain API before using MFC to make it easier. The API stands for the Application Program Interface and is what MFC uses anyway. It allows you to create windows and controls using lower level code.
See the Tutorials link at the top of the C/C++ forums for more info.
-
Jan 29th, 2002, 05:11 PM
#5
Thread Starter
Frenzied Member
yeah i know a lot about VB but not enough of C++ so i want to move on to the more professional language (or the language that most companies use).
How do the API's work in C++? are they the same as the API's in VB?
-
Jan 29th, 2002, 05:22 PM
#6
Member
The API is the same in C++ as in VB, except that the variables look a little different (there's pointers and structs) and you never need to declare the function ahead of time - you just include windows.h which does this for you automatically. So yes, if you know the API in VB you already have a head start in C++ because you can use some of the same code for API calls (with some changes of course).
-
Jan 29th, 2002, 05:54 PM
#7
Monday Morning Lunatic
Originally posted by SomethinCool
Code:
#include "iostream.h"
void main()
{
cout << "Pick a number: ";
int number;
cin >> number;
cout << "Your number was: " << number;
}
Since you're new, I'll be nice 
1. You should use angle-brackets not quotes: #include <iostream.h> since it's a system header.
2. You should be using the iostream header, not iostream.h which is the older version.
3. It's int main, not void.
4. You should have an endl after the last output of number. This puts a newline and flushes the output buffer so that anything else doesn't get mixed up with your program's output.
So, this is a corrected version:
Code:
#include <iostream>
using namespace std; // You need this for the new headers
int main() {
cout << "Pick a number: ";
int number;
cin >> number;
cout << "Your number was: " << number << endl;
return 0; // To go with the new function definition
}
The using namespace std; is something that you need for the standard c++ library, and you'll find out why it's important later on
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 29th, 2002, 08:01 PM
#8
Hyperactive Member
Yeah API is simple
PHP Code:
#include <windows.h>
float x;
x = GetTickCount(); //Api Function
Parskie: whats so special about std namespace?? yet i did not discover any features in new versions.
-
Jan 29th, 2002, 09:11 PM
#9
Thread Starter
Frenzied Member
Since you're new, I'll be nice
1. You should use angle-brackets not quotes: #include <iostream.h> since it's a system header.
2. You should be using the iostream header, not iostream.h which is the older version.
3. It's int main, not void.
4. You should have an endl after the last output of number. This puts a newline and flushes the output buffer so that anything else doesn't get mixed up with your program's output.
well..i usually put the angle brackets but i just dont care which ones i use.
in my C++ book that i have from school, (i'm only in 10th grade), it says to use void main(). Why should i use int main? i saw that somewhere also. Doesnt that declare it as an integer?
ok i will put endl at the end..i saw that also in a tutorial.
also...with that API
Code:
#include <windows.h>
float x;
x = GetTickCount(); //Api Function
you dont even have to do stuff like:
Private Declare Function GetTickCount lib "kernel32.dll" () as long
are the API's for windows all in that windows header file?
-
Jan 29th, 2002, 09:14 PM
#10
Thread Starter
Frenzied Member
also, one last thing....
how hard is it to make Windows Apps in C++
and.....
i want to get into graphics programming with C++ using DirectX, now, i've seen tutorials for DirectX in VB and that looks sorta hard. Is it easier to make DirectX programs in C++ or VB?
Sorry for the long post.
-
Jan 29th, 2002, 09:15 PM
#11
Fanatic Member
SomethinCool: Basically, you can think of it in these simple terms:
C++: A programming language, such as C, Delphi, Java, etc.
Visual C++: An IDE (integrated development environment) for C++. Some others are Dev-C++, Borland C++, etc.
MFC: Microsoft Foundation Classes. These help simplify window creation and the like, but are on the slow side. Note: some people call code with MFC in it Visual C++ code, so don't be fooled 
Made_of_asp: Not sure, but I think the std namespace and the standard headers are used for compatability on other platforms, where iostream.h can have compiler-specific things. Again, I'm not sure, maybe someone can clarify
Alcohol & calculus don't mix.
Never drink & derive.
-
Jan 29th, 2002, 09:19 PM
#12
Fanatic Member
Originally posted by SomethinCool
well..i usually put the angle brackets but i just dont care which ones i use.
in my C++ book that i have from school, (i'm only in 10th grade), it says to use void main(). Why should i use int main? i saw that somewhere also. Doesnt that declare it as an integer?
ok i will put endl at the end..i saw that also in a tutorial.
also...with that API
Code:
#include <windows.h>
float x;
x = GetTickCount(); //Api Function
you dont even have to do stuff like:
Private Declare Function GetTickCount lib "kernel32.dll" () as long
are the API's for windows all in that windows header file?
1. Angle brackets are for headers that come with the compiler (iostream for example). Quotes are for headers that are in the same directory as the source file, usually headers that you write yourself.
2. See this thread for an explanation.
3. You only have to include windows.h because all the API functions are already declared in it.
Alcohol & calculus don't mix.
Never drink & derive.
-
Jan 29th, 2002, 09:41 PM
#13
It should, actually be:
Code:
unsigned long x;
x = GetTickCount();
As for the angle brackets, i read this in a C programming book, but it should be the same for C++. The double quotes tell the compiler to look in the currect directory, THEN in the standard directories, while the angle brackets ignore the current directory, and simply look in the standard directories.
int main() is the correct way to define your main function. In fact, the correct way is (correct me if im wrong) int main(char* argv[], int argc), which allows you to parse command line arguments. Dont worry about that for now.
Namespaces are a C++ feature that allows you to encapsulate things in a common area. For example, when using classes, if you define an enum inside of the class, you access it through the class:
Code:
class x {
public:
x();
enum { a, b, c };
};
...
x::a;
Notice the double colons, which specify the scope of the enumeration. Namespaces are the same, except they add another layer of scope:
Code:
namespace myNamespace {
class x {
public:
x();
enum { a, b, c };
};
};
...
myNamespace::x::a;
Now, that is a lot to type. So, instead of typing all of that every time you use something, you tell the compiler to look in that namespace for things it cant find, like this:
Code:
using namespace myNamespace;
You could also do:
Code:
using myNamspace::x
to use class x without the myNamespace:: part, but not import the rest of the namespace.
The whole reason for namespaces is to prevent name duplication, so you may or may not want to import the entire namespace.
Z.
PS: I think that all of the above is correct, but it may not be =).
-
Jan 29th, 2002, 09:42 PM
#14
Hyperactive Member
C++ makes everything harder than VB. Building Win32 GUI App's from scratch isn't easy, but there are dialogs resources that can help. mfc requires some runtimes that even i don't have installed.
MFC: for true C++ App, don't use MFC. Raw API is a good solution to creating app's + you lean how to use WM's.
-
Jan 29th, 2002, 09:46 PM
#15
Thread Starter
Frenzied Member
ok how would you program a Win32 App using Raw API?
-
Jan 29th, 2002, 09:54 PM
#16
Frenzied Member
Im telling you right now you're not ready for it. You should really get the basics down first...
check out www.cprogramming.com they have some good tutorials.
-
Jan 30th, 2002, 04:37 AM
#17
Hyperactive Member
if you want to try win32 app's in VC++,
Code:
Visual C++ can create the main stuff for you. Visual C++ -> File/New -> Projects Tab -> Win32 Application -> OK -> A Typical Hello World Application
VC++ will create necessary code for a win32 window + some cursors, icons , string table, about dialog and some other stuff.
VC++ will create some message handlers including WM_DESTROY, WM_COMMAND, WM_PAINT.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|