Search Results

Showing results 1 to 40 of 46
Search took 0.01 seconds.
Search: Posts Made By: kbshibukumar
Forum: C++ Apr 9th, 2009
Replies: 10
Views: 639
Posted By kbshibukumar
Siddhant, everybody knows some variable preceded by & is a reference. What I meant is the actual parameter represented by head is a pointer to a list of pointers. That is exact in the case of a...
Forum: C++ Apr 9th, 2009
Replies: 4
Views: 381
Posted By kbshibukumar
Other than that, in function assign , you are using local variables, which make it meaningless.
Forum: C++ Apr 9th, 2009
Replies: 10
Views: 639
Posted By kbshibukumar
head is a pointer to a list of pointers. If you pass head only (passing by value), the changes on head won't have any effect. That is why you are passing it reference.
Forum: C++ Mar 24th, 2009
Replies: 8
Views: 689
Posted By kbshibukumar
I just tried it in VC++ 8 and it works fine for me. his is the program I tried.
Forum: C++ Mar 24th, 2009
Replies: 1
Views: 446
Posted By kbshibukumar
I'm not sure if C++ permits that.
Better you can try
Animal* a1 = new Animal();
Animal* d1 = new Dog()

Then you can use dynamic_cast, if needed
Forum: C++ Mar 24th, 2009
Replies: 8
Views: 689
Posted By kbshibukumar
I think it is because of buffering of cout. A call cout.flush() may help. (I didn't try it. So pls excuse if it is wrong)
Forum: C++ Mar 6th, 2009
Replies: 6
Solved: hash map in STL
Views: 3,340
Posted By kbshibukumar
I don't know if there is any stl hash_map. U need to use just map instead, with a #include <map>
Forum: C++ Mar 5th, 2009
Replies: 10
Views: 921
Posted By kbshibukumar
Do you have destructor for a function to clean up the locals inside?
Forum: C++ Mar 5th, 2009
Replies: 7
Views: 604
Posted By kbshibukumar
Forum: C++ Mar 5th, 2009
Replies: 4
Views: 291
Posted By kbshibukumar
OK.. I understood.
However, I think your sequence would enter the for loop only if both list1->getNxt() == NULL and list2->getNxt() == NULL because of the terminationg condition in for loop. Are you...
Forum: C++ Mar 5th, 2009
Replies: 7
Views: 604
Posted By kbshibukumar
A general way is to flush the input stream (instead of using getchar()).
Use
Forum: C++ Mar 5th, 2009
Replies: 6
Solved: hash map in STL
Views: 3,340
Posted By kbshibukumar
The map as a whole can not displayed using cout. Try
Forum: C++ Mar 5th, 2009
Replies: 4
Views: 291
Posted By kbshibukumar
Is the value of result != NULL when you invoke the function? I don't see you do a new operation on result anywhere in the function.

As you stated, if it is really non-null, the program would crash...
Forum: C++ Mar 5th, 2009
Replies: 6
Views: 629
Posted By kbshibukumar
Of course, if you put the delete statement after the return statement, it won't be executed at all. Instead you can do like
Forum: C++ Mar 5th, 2009
Replies: 6
Views: 629
Posted By kbshibukumar
If you are afraid of delete, using auto_ptr can be a good option.
Forum: C++ Mar 5th, 2009
Replies: 10
Views: 921
Posted By kbshibukumar
However, having multiple exit points for a function makes it difficult to maintain. There is a greater chance that you'll forget to do the clean ups (which will be usually at the end of the function).
Forum: C++ Mar 5th, 2009
Replies: 2
Views: 439
Posted By kbshibukumar
Why are you trying to read a double using "%d"? Use "%lf" instead.
Forum: C++ Mar 4th, 2009
Replies: 5
Views: 254
Posted By kbshibukumar
Yes you are right. My apologies...
Thanks for correcting me.
Forum: C++ Mar 4th, 2009
Replies: 8
Views: 271
Posted By kbshibukumar
Try this.
http://cppkid.wordpress.com/2009/02/18/how-to-round-off-a-number/
Forum: C++ Mar 4th, 2009
Replies: 5
Views: 254
Posted By kbshibukumar
You don't have to go upto sqrt(num). The loop may be like this.
Forum: C++ Feb 27th, 2009
Replies: 3
Views: 548
Posted By kbshibukumar
To sort an array, see the following article. It is simpler than you writing your own algorithm.

http://cppkid.wordpress.com/?s=how+to+sort+an+array
Forum: C++ Feb 19th, 2009
Replies: 7
Views: 1,075
Posted By kbshibukumar
The problem is that when your function is returning a string, it first makes a copy of the string to be returned (in your case, it is NULL). For making copy, it has to take the length of the original...
Forum: C++ Feb 18th, 2009
Replies: 6
Views: 736
Posted By kbshibukumar
This may be helpful to round off a number.
http://cppkid.wordpress.com/2009/02/18/how-to-round-off-a-number/
Forum: C++ Feb 18th, 2009
Replies: 4
Views: 292
Posted By kbshibukumar
The problem seems to be in

while(isalpha(ch))
{
text[i] = ch;
i++;
}

If the first character is an alphabet, it will go on filling the array text with that...
Forum: C++ Feb 18th, 2009
Replies: 2
Views: 534
Posted By kbshibukumar
The question is not much clear to me. I assume that you have a class with a public member, say

class CMyClass
{
public:
int iNo;
};

Then you can access iNo as
Forum: C++ Feb 11th, 2009
Replies: 2
Views: 392
Posted By kbshibukumar
Exactly........
Have a better practice to initialize Point at the time of declaration.
Forum: C++ Feb 11th, 2009
Replies: 3
Views: 285
Posted By kbshibukumar
I'm not sure what type of a vector stuAns is.
If it is a vector of char*, you have to use strcmp() instead of checking with the operator !=.
Forum: C++ Feb 9th, 2009
Replies: 7
Views: 916
Posted By kbshibukumar
I think you can simply check if the first character is a numeral.
Forum: C++ Feb 9th, 2009
Replies: 3
Views: 770
Posted By kbshibukumar
isn't it possible to use a map rather than using two separate vectors? Then, I think, the entire problem will be solved.
Forum: C++ Feb 9th, 2009
Replies: 4
Views: 928
Posted By kbshibukumar
Please refer to this link. It may be helpful.

http://www.codeproject.com/KB/database/cspreadsheet.aspx
Forum: C++ Feb 9th, 2009
Replies: 2
Views: 1,091
Posted By kbshibukumar
Sorting the stack is easy. I have written in my blog how to sort an array in simple steps.

http://cppkid.wordpress.com/2008/09/18/how-to-sort-an-array/

Hope this will clear your problem.
Forum: C++ Feb 9th, 2009
Replies: 3
Views: 505
Posted By kbshibukumar
The operators like . , -> and * can not be overloaded.
Forum: C++ Feb 9th, 2009
Replies: 4
Views: 583
Posted By kbshibukumar
only the first example invokes copy constructor. If the second one needs to work in the same manner as copy constructor does, you have to overload the assignment operator.
Forum: C++ Feb 9th, 2009
Replies: 7
Views: 2,192
Posted By kbshibukumar
Of course this will work. However, what is the need of a separate class just to implement the < operator. Does it have any more advantage than implementing in the struct itself?
Forum: C++ Feb 3rd, 2009
Replies: 7
Views: 2,192
Posted By kbshibukumar
To use find function, you have to implement operator < in the key struct. Then it will be ok.
Once I had a similar problem in sorting a vector and I have written it in my blog....
Forum: C++ Feb 3rd, 2009
Replies: 5
Views: 527
Posted By kbshibukumar
Which compiler are you using? I'm using Visual Studio 2005 and the code compiles perfectly. Also, it creates an array of pointers to objects.
Forum: C++ Feb 3rd, 2009
Replies: 5
Views: 527
Posted By kbshibukumar
Instead of the line

Foo* f = new Foo[2]("Hello");

you have to use

Foo* f[] = {new Foo("Hello"), new Foo("Hello"));

Then for deleting, you have to iterate throgh each element of the array.
Forum: C++ Jan 23rd, 2009
Replies: 3
Views: 328
Posted By kbshibukumar
p is the object itself (just another name for *obj, not obj). References are internally treated as pointers. However, it is hidden from the programmer.
Forum: C++ Jan 15th, 2009
Replies: 8
Views: 989
Posted By kbshibukumar
How the value of PI can be printed as a table?
Forum: C++ Jan 15th, 2009
Replies: 8
Views: 526
Posted By kbshibukumar
[] operator is the best to add values to an array, I think. Applicable only if you know the index in advance.
If you have to search in runtime for the position to which we can add a value, it will...
Showing results 1 to 40 of 46

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC