Forum: C++ 5 Days Ago |
| Replies: 7 Views: 247 So what happens when this function returns?
//suppose i have 2 objects of A somewhere above c,d,
//i assign d to c;
c = d;
'this' (c) gets overwritten by this new object 'a' that we are... |
Forum: C++ 5 Days Ago |
| Replies: 7 Views: 247 I want to define an assignment operator for my the class A. something like
A& operator=(const A& right)
{
//not too sure on how to copy the pointers correctly here.
return *this;
} |
Forum: C++ 5 Days Ago |
| Replies: 7 Views: 247 class A: public B
{
C* p1;
C* p2;
}
What would be a correct assignment operator for class A? We have to ensure that we do not leave any object in an inconsistent state due to any exceptions... |
Forum: C++ 9 Days Ago |
| Replies: 8 Views: 312 you can write a function to check if the value is equal to any of those given values and return a bool value
for example:
bool checkValue(char c)
{
return ((c == 'r') || (c == 'p') ||... |
Forum: C++ 9 Days Ago |
| Replies: 8 Views: 312 while( (g.one != 'r') || (g.two != 'p') || (g.three != 'g') || (g.four != 'm'))
that's how you give multiple values, you can modify it to suit your requirement |
Forum: C++ 9 Days Ago |
| Replies: 1 Views: 145 You would have to do a few things before someone can help you
1> post some code, show what you have tried
2> state the problem clearly so that we can try and get our heads around it. , state... |
Forum: C++ 10 Days Ago |
| Replies: 4 Views: 312 //input/output functions
//void read();
friend istream &operator>>(istream &str, Date&d)
{
char skip_char;
str >> mn >> skip_char >> dy >> skip_char >> yr;
} |
Forum: C++ 10 Days Ago |
| Replies: 5 Views: 252 You need to provide an implementation for all the arithmetic functions , something like this
Fraction Fraction::Multiply(Fraction frac1) const
// Pre: frac1 and self have been initialized.... |
Forum: C++ 11 Days Ago |
| Replies: 10 Views: 423 And
c) Make sure you have copy ctor
d) Define a proper assignment operator for your class
I would still advise you to use a vector unless you are bound to using a raw array. Read here for more... |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 191 First things first. You need to make your code syntactically correct
1> change #include <iostream.h> to #include <iostream>
2> void main() should be changed to int main() . Don't use void main... |
Forum: C++ 11 Days Ago |
| Replies: 10 Views: 423 Why don't you use a 'vector' class instead of arrays? It would be much easier to use. |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 191 Oh God..not again .. I think we need a background script to find such threads and give suitable advice to the OPs' :( ...
We don't give homework help, if you show some effort, we will try to help... |
Forum: C++ 11 Days Ago |
| Replies: 2 Views: 246 Please state clearly what problem you are trying to solve and what are the difficulties you are facing. Don't expect us to read through your code and find out the problem. |
Forum: C++ 15 Days Ago |
| Replies: 1 Views: 135 The way you have written your question, it is quite difficult to understand what you have and what you want to do. Can you re-phrase your question clearly? |
Forum: C++ 16 Days Ago |
| Replies: 14 Views: 259 Since this is your first post, please read about code tags and learn to use them if you want people to read your code.
Read About Code Tags Here... |
Forum: C++ 16 Days Ago |
| Replies: 4 Views: 253 I doubt if your professor wants you to overload operator '>>'. If not then as I mentioned in my post above, take input into int or float and call the ctor. Otherwise, I don't think you have... |
Forum: C++ 16 Days Ago |
| Replies: 4 Views: 253 line 145, 147: you cannot just directly read user input into RationalNumbers variable (unless you do some operator overloading and I don't think you need to do that). Take it into a standard data... |
Forum: C++ 20 Days Ago |
| Replies: 5 Views: 244 By binomial coefficient you mean finding the combinatorial number, is that right ? So you should be using the formula n!/(n-k)!*k!
for this the pseudocode should be
numerator=1*2*3..*n
fact1 =... |
Forum: C++ 25 Days Ago |
| Replies: 11 Views: 493 It's quite sad that you have flicked somebody else's code, and without acknowledement :( .. Source (http://worldofbrock.blogspot.com/2009/10/how-to-implement-dijkstras-algorithm.html). What's the... |
Forum: C++ 25 Days Ago |
| Replies: 11 Views: 493 post your code, whatever you have done. Lets take a look |
Forum: C++ 25 Days Ago |
| Replies: 11 Views: 493 This looks like a shortest path problem. You can consider each element to be a vertex in a graph (so you have 12 vertices for the first matrix) and only connected to vertices directly to... |
Forum: C++ Oct 21st, 2009 |
| Replies: 5 Views: 321 Its surprising that you are not able to compile it in windows. If you take a library compiled in *NIX, it would not run on windows but usually the code compiles fine both on windows n *nix, apart... |
Forum: C++ Oct 17th, 2009 |
| Replies: 1 Views: 243 Unfortunately you havn't done enough to make us help u... you can find out a lot of material about tree traversal here, infact you can see similar threads at the bottom of this page too. Read them... |
Forum: C++ Oct 2nd, 2009 |
| Replies: 2 Views: 187 matrixType::matrixType()
{
maxRow = 5;
maxCol = 5;
matrix = new int*[maxRow];
for (int row = 0; row > maxRow; row++)
matrix[row] = new int[maxCol];
for(int i = 0; i > maxRow; i++)
for(int j =... |
Forum: C++ Jul 15th, 2009 |
| Replies: 4 Views: 447 Is this the exact code you compiled? And is that the only error you got? Your code has a lot of other compiler errors too as of now. It'll be good if you paste the entire code after you remove all... |
Forum: C++ Jul 14th, 2009 |
| Replies: 5 Views: 281 I don't really understand what you are doing. You just have an array of structures of type wordList. So basically you are not using the linked list at all !!! You create a node and insert it into the... |
Forum: C++ Jul 13th, 2009 |
| Replies: 4 Views: 342 you need to pass the reference to the pointer to make it work. You are just modifying the copy of the pointer here. So the changes will not be visible once you leave the fn.
fn signature could be... |
Forum: C++ Jul 13th, 2009 |
| Replies: 3 Views: 278 This thread here talks about float comparisons. There's a good link available in the thread about the same.
Thread1 (http://www.daniweb.com/forums/thread73810.html) |
Forum: C++ Jul 1st, 2009 |
| Replies: 10 Views: 451 And who are 'they' ?? My opinion, C++ is way harder than Java, so don't start with wrong notions. |
Forum: C++ Jul 1st, 2009 |
| Replies: 6 Views: 542 void int_to_hex(int *dez,string& hex_string); |
Forum: C++ Jul 1st, 2009 |
| Replies: 3 Views: 434 If you are compiling them one-by-one make sure you only compile and don't go to the linking process. I think you might be doing that and while trying to create an executable its not finding main.... |
Forum: C++ Jun 29th, 2009 |
| Replies: 13 Views: 584 Why don't you post the problem statement first. Then explain how you are trying to achieve it in your code. Then as I said, read about data-types. how did you find out about c_str fn? And I posted... |
Forum: C++ Jun 29th, 2009 |
| Replies: 13 Views: 584 Hmmm.. don't know where to start from. First things first, 'num' is of type 'char', do you have a class 'char' which has a fn c_str defined? No. Its a fn of the 'string' class. Then you didn't even... |
Forum: C++ Jun 29th, 2009 |
| Replies: 13 Views: 584 1->atoi signature is this:
int atoi ( const char * str );
2-> read some more threads here to find out alternatives to atoi. You should avoid using it. |
Forum: C++ Jun 26th, 2009 |
| Replies: 2 Views: 364 Before even going into your logic i have a couple of things I can tell you
1-> Read the code-tags page carefully and learn to use them correctly. it would make your code much easier to read.
2->... |
Forum: C++ Jun 26th, 2009 |
| Replies: 6 Views: 443 Well i copied your class, created a class definition out of whatever was given and used it and it worked fine for me.
#include <iostream>
#include <fstream>
#include <string>
class... |
Forum: C++ Jun 13th, 2009 |
| Replies: 4 Views: 320 well no I'm not sure it is inefficient, actually i don't really know how to calculate efficiency and that's the whole reason I had to post it here. Someone who knows how to do that would tell me if... |
Forum: C++ Jun 12th, 2009 |
| Replies: 4 Views: 320 hey guys,
I have a fixed length .txt file. Values in the file correspond to columns in a db table.
ex file row is something like:
India 3455 78787 89898
table has columns... |
Forum: C++ Apr 23rd, 2009 |
| Replies: 11 Views: 476 I don't know what more it can tell you, if you read the error message carefully it says everything. _search needs a parameter of type NODE<TYPE>** and you are passing it NODE<TYPE>* , so either... |
Forum: C++ Apr 20th, 2009 |
| Replies: 6 Views: 383 My bad, i didn't see the function signature properly, you're returning by value so the copy ctor will get called.
that doesn't seem to be so because
maxItems = sB.maxItems;
and hence... |