Forum: C++ Oct 24th, 2005 |
| Replies: 13 Views: 9,856 template member functions may not be virtual but often you can get around this by templating a class rather than a member function. The only reason you cant have template member functions is because... |
Forum: C++ Oct 12th, 2005 |
| Replies: 1 Views: 7,392 there is a need and a reason to return arrays and it can be done, you just return a pointer to its first address. If what you meant was an array return by value, i.e. a copy of the array then yes... |
Forum: C++ Oct 11th, 2005 |
| Replies: 6 Views: 8,588 private inheritance has its uses. It is similar in effect to composition and nothing like public inheritance. When you become more familiar with c++, you will often find uses for private inheritance. |
Forum: C++ Oct 11th, 2005 |
| Replies: 6 Views: 8,588 no its not legal. because you have used private inheritance your class now looks like this.....
class Bird
{
public:
Bird();
virtual ~Bird();
private:
void... |
Forum: C++ Oct 6th, 2005 |
| Replies: 2 Views: 9,244 it is. passing a pointer is no different to passing anything else. Its a parameter the same as any other. |
Forum: C++ Oct 4th, 2005 |
| Replies: 4 Views: 3,321 well in c++ you dont need to do that. you can get input like this....
int an_int;
while( ! cin>>an_int )
{
// didnt get an int so deal with that here
cin.clear(); // clear error flags
... |
Forum: C++ Oct 4th, 2005 |
| Replies: 8 Views: 14,868 you appear to be mixing managed and unmanaged c++. I dont think you can do that although I aint sure i dont use managed c++ |
Forum: C++ Oct 4th, 2005 |
| Replies: 2 Views: 4,414 something like
long long int summation(long long int start, long long int howMany)
{
long long sum=0;
for(long long i=0,j=start;i<howMany;++i,++j)
sum += j;
return sum;
} |
Forum: C++ Oct 4th, 2005 |
| Replies: 4 Views: 3,321 perhaps if you explain better what you are trying to do. maybe a small code sample. Why would you need to type check after a cin. |
Forum: C++ Oct 2nd, 2005 |
| Replies: 2 Views: 1,174 Its extrememly dated. If you are in any way serious about programming you will want the best tools you can get for free or for the money available. There are many compilers available for free on the... |
Forum: C++ Oct 2nd, 2005 |
| Replies: 11 Views: 2,589 understand what the code is doing. In main you make an input file and read it a line at a time. You then pass that line to myjob::read. This is where the parsing occurs. first an istringstream is... |
Forum: C++ Sep 30th, 2005 |
| Replies: 8 Views: 14,868 |
Forum: C++ Sep 30th, 2005 |
| Replies: 1 Views: 1,212 |
Forum: C++ Sep 29th, 2005 |
| Replies: 8 Views: 14,868 look up in your helpfiles or at msdn....
the third param to WinMain to get command line as ascii
GetCommandLine() to get the command line as unicode
CommandLineToArgvW() to convert it to an... |
Forum: C++ Sep 29th, 2005 |
| Replies: 2 Views: 1,348 we dont do your homework, we only help when you show effort. |
Forum: C++ Sep 28th, 2005 |
| Replies: 1 Views: 7,521 know how to write a text file? should be examples in all c++ texts. or alternatively there are a couple of libraries available to do logging, check on sourceforge. |
Forum: C++ Sep 28th, 2005 |
| Replies: 10 Views: 2,685 What compiler are you using?
You will need something reasonably standards conforming. You can get one in my sig. |
Forum: C++ Sep 28th, 2005 |
| Replies: 10 Views: 2,685 what I meant is illustrated below. it breaks my heart to write all of this in the main function but it seems as if you havent learnt functions yet so I tried not to get too far ahead. I have shown... |
Forum: C++ Sep 27th, 2005 |
| Replies: 10 Views: 2,685 ok then.
firstly the correct header is <iostream> not <iostream.h>.
using std::cout;
using std::cin;
using std::endl;
can be removed. You have already said that you are using the whole of... |
Forum: C++ Sep 27th, 2005 |
| Replies: 10 Views: 2,685 post some code to show you have attempted the problem if you want help. We dont handfeed you homework answers but will happily help you out if you show effort. |
Forum: C++ Sep 26th, 2005 |
| Replies: 2 Views: 2,289 ptr.speak();
ptr.move();
ptr.printName();
not . its -> |
Forum: C++ Sep 25th, 2005 |
| Replies: 13 Views: 2,718 int a=rand();
int b=rand();
int c=rand();
std::vector<int> vec;
vec.push_back(a);
vec.push_back(b);
vec.push_back(c);
std::cout<< *std::min_element(vec.begin(),vec.end())<<std::endl;
not a... |
Forum: C++ Sep 25th, 2005 |
| Replies: 15 Views: 3,696 yes it is standard, but it took a while for some compilers to catch up, most notably msvc6. There is also a nothrow version of new specified by the standard. |
Forum: C++ Sep 25th, 2005 |
| Replies: 8 Views: 2,127 you cant. watch.
int x=0; // global x
int main()
{
int x=1; // main x
{
int x=2; // block x
cout<< x<<endl; // prints block x |
Forum: C++ Sep 21st, 2005 |
| Replies: 9 Views: 2,047 your probably overstepping the bounds of an array somewhere. Other than that its hard to say without seeing code. we are not psychics. |
Forum: C++ Sep 21st, 2005 |
| Replies: 5 Views: 2,970 operator ++ and -- with no arguments return a reference to an object and not an object itself. bman you should have known better. |
Forum: C++ Sep 20th, 2005 |
| Replies: 8 Views: 5,305 protected data members are virtually a no-no. what normally goes into the protected section are member functions, especially virtuals which may need to be called from derived classes but not... |
Forum: C++ Sep 20th, 2005 |
| Replies: 2 Views: 1,256 Your hangman class is missing a }; at the end. take care to punctuate properly |
Forum: C++ Sep 20th, 2005 |
| Replies: 7 Views: 11,403 |
Forum: C++ Sep 18th, 2005 |
| Replies: 4 Views: 2,370 no as an array.
yes as a pointer or object such as std::vector |
Forum: C++ Sep 16th, 2005 |
| Replies: 1 Views: 1,167 I fail to see whats so special about vista. I have checked out the beta. All the things I was looking forward to didnt make it in. Its not that much different from XP. What have the microsoft... |
Forum: C++ Sep 16th, 2005 |
| Replies: 3 Views: 1,552 typo here
cout<<" Enter your last name :";
cin>> last;
cout<<" Enter your last name :"<<endl;
cin>>first; |
Forum: C++ Sep 14th, 2005 |
| Replies: 5 Views: 3,054 you dont need to know windows api to use opengl. its independant of windows. The only time you need windows coding is if you want your opengl app to run in a window instead of full screen.
theres... |
Forum: C++ Sep 14th, 2005 |
| Replies: 7 Views: 2,952 ok might be a bug. somethings trampling on your vector. Set a watch on the vectors first few elements and single step thru your code in a debugger. watch for the point where the trampling occurs and... |
Forum: C++ Sep 13th, 2005 |
| Replies: 7 Views: 2,952 lol there is no bug dave. its a feature! |
Forum: C++ Sep 13th, 2005 |
| Replies: 7 Views: 2,952 read this all should become clearer (http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=205&rl=1) |
Forum: C++ Sep 13th, 2005 |
| Replies: 8 Views: 7,798 ok lets go thru your code....
your exception classes will need default constructors or arguments passed to them.
destructor doesnt need if(s). just the delete[]s will do nicely.
throw... |
Forum: C++ Sep 13th, 2005 |
| Replies: 8 Views: 7,798 why stacks?
Heres a palindrome proggy i did for another board.
#include <iostream>
#include <string>
#include <cctype>
int IsMirrorPalindrome( const char* word, size_t length )
{
if(... |
Forum: C++ Sep 13th, 2005 |
| Replies: 3 Views: 1,827 how do you know whats in stock? do you read that info from a file? you gotta enter it by hand?
You can use the STL to simplify your exercise.
I would probably use a sorted vector of structs(or... |
Forum: C++ Sep 12th, 2005 |
| Replies: 8 Views: 3,843 its gotta be. If you include string in the first example, it should work. If you include functional in mine, it will work and also daishis example is valid too. You can get a different version of the... |