I don't think s3abass will be able to answer, seeing that he hasn't been in these forums for so long :P. I'll also ask a question, hoping someone else knows the answer: How do I go about making...
Type: Posts; User: Mr.Pointer
I don't think s3abass will be able to answer, seeing that he hasn't been in these forums for so long :P. I'll also ask a question, hoping someone else knows the answer: How do I go about making...
So temporary objects are always const, which is something I didn't know. Thanks :D
Whoops, I'm really sorry, I wrote a bad example! What I meant to write was something like this:
Number a = 20;
a = 40;
The constructor is indeed called twice, and your explanation makes a lot of...
Like I said, this happens when I remove the copy assignment operator, and when the class doesn't have an assignment operator for an int, it calls the constructor.
I used g++ for the above code and it compiled.
Why are you declaring an array with a variable size? Not all compilers can support it.
EDIT: too late :P
I decided to start an extremely simple experiment to revise on things I already know, but came across two things that puzzled me. I have a class named Number, which only holds an integer named...
You have two syntax errors. One of them has to do with something you (probably) forgot to do, the other has to do with something you're not allowed to do.
Even with those errors fixed, there's a...
it's funny, I had the exact same problem the first time I tried to learn how to use classes! I suggest you follow the convention mentioned by anon, which is to use the upper-case character for type...
I once took a quiz that asked me to write a case-insensitive version of strcmp. What I did was to simply compare every pair of characters (one from each string) after I had converted them to...
Almost everything I come across to reminds me of something programming oriented. For example, someone on MSN yesterday called me mr T, and the first thing that came into my mind was "template <class...
I actually use a combination of both. For debugging, I compile at cygwin with a custom makefile and run gdb through the console. I find it more convenient this way. But, when it comes to everything...
Thank you for your suggestion, I will keep that in mind. I'm still practicing and learning along the way, so "functors" and C++0x lambdas are things I've not covered yet. But, I will get to them...
there's not a fixed size for int. It's usually 4, but can be different in other systems. That's why sizeof() exists, it's a function that returns the size (in bytes) of a data type.
Thank you very much, that did the trick! It makes a lot of sense too, now that I think of it.
I applied it the idea to my actual program as well, and it's working :D
I managed to isolate a problem I'm having to this example program:
#include <iostream>
using namespace std;
//Simple inheritance
class Parent {};
class Child: public Parent {};
//Functions
Code::Blocks
I love it. It's free, portable, powerful, simple, and looks so pretty. Supports C and C++, and other languages as well.
Code::Blocks is an IDE that works with many compilers, it's not a compiler... The mistake is that you did not specify the correct settings for the compiler you want to use (most likely the directory...
I've no idea why, but putting:
getline(cin, choice);
instead of
cin >> choice;
seems to work.
Perhaps a more experienced programmer could enlighten us as to why. I have a feeling it's...
The first one is wrong with only a first glance. Evaluate it step by step. What is the mistake?
The second one is almost correct. Tip: You know that in C strings can be shorter than the array's...
There are many things wrong with your code.
temp=line next_Id(c[0] , 666666666);
should be
temp= next_Id(c[0] , 666666666);
...
I don't know what the warnings mean, but did you compile with the -g flag?
gcc -g program.c
This will put the debugging symbols and it might work for you despite the warnings (I personally...
Thank you for your replies! For the sake of my assignment, I'll use the method you suggested, which is having a default comparing function but also the possibility to accept other comparing...
Yeah, like I said, he should use the functions suggested to him. I just thought it would be very important to understand just why it produced a syntax error.
Not that it changes anything in the...
temp[0] = '\0';
This will produce no syntax errors.
Anything contained within "quotes" can be considered as a char* pointer, even if there's a single character in it. So, by putting temp[0] =...
Hello all,
I'm new to C++ but I do understand the basics of programming. I've recently started getting serious and intend to go "pro" with it.
I made a template LinkedList that can accept any...