|
Hehehe thanks for your information and time. I really do appreciate it.
Raistlin
|
|
|
|
|
I didn't see anything in the tutorials that was a good fit. Christian is an MVP for Microsoft C++ and that means he's been helping people for a long time. He might have some good advice at this point because what I'm about to tell you taps out mine. Learning this stuff is a bit like learning to ride a bike. You have to ride a lot and crash a lot before you internalize what it takes to ride a bike and then you'll never forget it.
My advice at this point. Go back to the books you have bought on C++ and go over them. Write all the examples and step through the programs. Read, re-read then read again the descriptions of the concepts involved. Relevant words to your questions right now are:
Inheritance - overloading
Things I think you should really focus on learning are the basics.
1. First learn and memorize (go over it until you can vomit it) the basic data types like int and char.
2. Then learn looping. for, while, do, etc...
3. Then learn how classes are written. This will cover function overloading, constructors, destructors and other key ideas.
If you get this far you are a long ways toward being really good. But to get this far you have lots of hours of struggling ahead of you.
Christian, do you have other ideas or suggestions? I only jumped in here because I ran this guy out of the lounge. You->MVP me C++ developer but not a teacher. I'll defer to your experience at this point.
- Rex
My name is Maximus Decimus Meridius, commander of the Armies of the North, General of the Felix Legions, loyal servant to the true emperor, Marcus Aurelius. Father to a murdered son, husband to a murdered wife. And I will finish this project, in this life or the next. Slightly modified " from Gladiator.
Code-frog System Architects, Inc.
|
|
|
|
|
Raistlfiren wrote:
Whenever I look at different tutorials I notice this:
#! /usr/local/bin/python
That's just to indicate to the shell as to where the python interpreter is present. I guess it's in your PATH environment variable, so you don't need that line of code.
Raistlfiren wrote:
Is there a right way to right a C++ program?
There are only two ways main can be written and you've listed both of them. The first one is used when you don't bother about command line arguments, the second one when you have to use them.
What other way did you find?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Well, the other way was this :
#include <iostream><br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";<br />
cin.get();<br />
}
Yes it is the same way , but it has the "using namespace std;"... What does that represent? The other way doesn't have it... Just a little bit confused as you can see...
Raistlin
|
|
|
|
|
All that stuff you're worried about are used when needed. Don't worry about them until you need them. using namespace:std will not change anything unless you're using someting in std. Don't worry about it until you know what that means.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Raistlfiren wrote:
Is there a right way to right a C++ program?
So long as main returns int and either takes these arguments, or takes none, it's right.
Raistlfiren wrote:
Are they all right ways?
Yes.
Raistlfiren wrote:
What does it all mean?
#include means to include an external file, and #include < > means to include a library file, not one in your project. For example, iostream is the streaming classes, string is the string classes. Note these files do not have .h after then, iostream.h is wrong.
The arguments in the second case are the number of arguments and the arguments passed on the command line, like when you type myProgram.exe /?, /? is the one argument, which is passed in.
namespaces are used to hide parts of the program from each other, namespace std is where the standard library sits. using namespace std makes all those things globally visible, otherwise you'd need to put using std::string, etc, for each class in std you want to use, or use std::string where-ever you used it in code.
I suggest you buy a book called 'Teach yourself C++ in 24 hours', I found that book very good when I was at your level of understanding. And obviously, keep asking those questions when you get stuck.
Why Python ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So wait wouldn't this be right though: #include <iostream.h>? Sorry, for the wait, but I am trying to comprehend the second sentence :
Christian Graus wrote:
For example, iostream is the streaming classes, string is the string classes.
I don't quiet understand this right here... So are string classes the same as this : big = dog... String classes define words, like x = 8. So string classes are all of the classes that define words like if I were to say "cout << big" it would then say dog in the displayed text? Those are string classes?
Then, the file you type in command prompt is what the arguements define?
So where is this standard library at that defines namespace std? Then use std::string to define a library that is in the namespace library?
Christian Graus wrote:
Why Python ? I am kind of just trying out a whole bunch of programming languages, I currently have stuff on my computer for Perl, Python, C++, JAVA, visual basic, and dos batch files. A lot of those programs are ran by command prompt so they don't cost anything... I was looking at python though because it is multi platformed and is rather easy. Plus I was getting so annoyed at JAVA and C++, because I wasn't understanding it, that I was fed up with it. I was also loosing interest fast, so Python and perl kept me going for a little bit. Looking up good resources is rather hard sometimes...
Raistlin
|
|
|
|
|
My first thought is that you seem to be trying to learn too much at once. Stick with one language and get some confidence with that first.
But if you really do want to tackle C++ then this online tutorial looks quite good.
http://cplus.about.com/od/beginnerctutorial/l/blcplustut.htm
[^]
The pages are displaying slightly weird at the moment though. It explains each element in a step-by-step manner.
Kevin
|
|
|
|
|
The C++ string class (a.k.a. std::string ) is used to store and manipulate character strings. Yes, if you have defined:
string big = "dog";
then cout << big; will output dog .
The namespace std isn't defined in any library, it's defined in the standard C++ header files. If you want to define a new namespace for your code, you wrap the function, class and variable definitions in a namespace block:
namespace library {
class Foo;
void function1(const std::string&);
}
Now Foo and function1() are in namespace library , and you refer to them as library::Foo and library::function1() .
|
|
|
|
|
So if I were wanting to make a big math program for a calulator for my program, the namespace library allows me to define it and store my own library as my own? so if I were to make another program that required that calculator make up I could just call that library back to play??
Raistlin
|
|
|
|
|
<small><b>Raistlfiren wrote:</b></small>
<i>So wait wouldn't this be right though: #include ?</i>
If you check 'Do not treat <'s as HTML tags', then I can see your includes. I've looked at the page source, and you're asking if #include <iostream.h> is right. No, it's not. The header is there, and will work, but it's not valid C++, it predates the C++ standard. If your book says to use it, burn the book and buy a decent one. You should #include <iostream>, which means you need to put using std::cout;, etc. as it places those things in namespace std.
Raistlfiren wrote:
So string classes are all of the classes that define words like if I were to say "cout << big" it would then say dog in the displayed text? Those are string classes?
YEs, as someone else explained, if you #include <string>, then you can do this
string big = "dog";
cout << big;
A string class gives you a lot more than a container, you can search in the string, and do operations on it, and it handles the memory allocations for you.
Raistlfiren wrote:
Then, the file you type in command prompt is what the arguements define?
What do you mean ?
Raistlfiren wrote:
So where is this standard library at that defines namespace std?
It's in a subdirectory of your compiler, and your compiler is set up to look there for files, that's what the #include <> means, to look in library directories, #include "string" would look in the local directory first.
Raistlfiren wrote:
Then use std::string to define a library that is in the namespace library?
using std::string tells the compiler that when you type string in the global namespace, to use the one in std. You also need to #include it, so it knows about it.
Raistlfiren wrote:
I am kind of just trying out a whole bunch of programming languages
I'd suggest you don't. Stick with one, until you know it. And don't worry that you don't know it all, start in a corner and learn one bit, then move on from there. Write some simple programs ( for example, I wrote a command line calculator early on ), and treat them as exercises that will expand your knowledge.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the great information!
Christian Graus wrote:
Raistlfiren wrote:
Then, the file you type in command prompt is what the arguements define?
What do you mean ?
If I only knew what I mean! I think you guys have answered a lot of my questions already, and I will check out those tutorials that you have sent me. The only problem is that I want ot know a lot of each language and in a short period of time. I have different reasons to learn each programming language... Anyway, like I said your help was muchly appreciated!
Thanks,
Raistlin
|
|
|
|
|
Raistlfiren wrote:
Thanks for the great information!
Happy to help
Raistlfiren wrote:
The only problem is that I want ot know a lot of each language and in a short period of time.
You're better off looking for deep understanding than broad. Understand the thing you're looking at for now really well, instead of trying to have a bit of an understanding over a broad range in the short term.
Good luck !!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'll second the opinion that you're trying to do too much at once, a classic formula for frustration and confusion. I believe a good approach for you would be to pick a language -- interpreted languages like Python are better for learning than C++, IMHO -- find a good book on learning to program using that language, and have fun. Note that a book on learning Python, and a book on learning programming using Python are two different things, and you want the latter. How to Think Like a Computer Scientist[^] might be a good place to start. Also note that Google, and the internet in general, can be your enemy in this endeavor as well as your friend; there's a tremendous amount of information out there, and Sturgeon's Law ("90% of everything is crap") definitely applies. The folks here on CP are a tremendous source of knowledge, and are always helpful when you really get stuck. Just make the effort to find the answers yourself first -- you'll learn more that way. Oh, and whatever you do, don't post programming questions in the Lounge. That way lies madness...
|
|
|
|
|
I usually do find most of my information, though the questions here I displayed I have not been able to find or I haven't understood it should be better to say... Yeah I am probably the person who find the 90% of crap and I never find the 10% of good stuff..I have learned hard lesson of not posting in the Lounge computer programming questions. lol
-Raistlin
|
|
|
|
|
Raistlfiren wrote:
Yeah I am probably the person who find the 90% of crap and I never find the 10% of good stuff
But you DID find CodeProject
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
LoL.. This is one of the only 10% site site.
Raistlin
|
|
|
|
|
Hi All,
I am a newbie to visual C++ and .NET. I am working on a project which involves Visual C++ , MFC. I have an application and when I compile and run it I get a bunch of:
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MpApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c017.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c019.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c019.
First-chance exception at 0x7c81f070 in MyApp.exe: 0xC0000005: Access violation reading location 0x0000c019.
I have no idea why this happens and do not know how to go about debugging this. Also after showing all this exception my application runs fine. I made changes to the Debugger to break into the code on the exception and the first exception occurs in a windows file oleinit.cpp at the line:
SCODE sc = ::OleInitialize(NULL);
Please give me some guidance/pointers of what to do.
Thanks to All
|
|
|
|
|
The short answer: Never mind first-chance exceptions. They are not bugs. They are just what it says: a first chance to handle an exception. They will be send to you to give you an opportunity to handle the exception before the framework gets to it, but I have never seen a case where I needed to deal with a first-chance exception. They will usually be handled quite sufficiently by the framework.
The exceptions you get are probably due to memory being allocated but not committed, or memory not being allocated yet. My guess is that OleInitialize uses these exceptions in its memory allocation scheme and that they are part of normal execution.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi all,
I have a linked list of
typedef struct someStruct{
DatasourasRex someData;
someStruct *nextElement;
}someStruct;
so I have a list where 1 of these points to the second and a second points to the 3rd. I wish to remove the second so I have just set the pointer to point to the 3rd. But Id imagine this would give me problems with memory leaks maybe? I have used malloc each time to give me the memory, so how do I deallocate?
Thanks in advance
|
|
|
|
|
Use free
There's a link to an example at the bottom of the page.
In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock!
-- Harry Lime
|
|
|
|
|
NEVER use free unless you use malloc and NEVER use malloc if you're using C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Why? I always automatically use 'new' and 'delete' in C++, but i'm just curious what your 'motivations' are for not using 'malloc' and 'free' in C++.
Er zit een korstje op mijn aars.
|
|
|
|
|
new and delete use constructors/destructors and let you make full use of OO, malloc and free only control memory.
Elaine
The tigress is here
|
|
|
|
|
If you are using objects, which have constructors and destructors, malloc() and free() will not work. The new and delete operators will, however. Allocating room for other types such as int , char , and double will work just fine with malloc() and free() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|