Forum: C++ Feb 10th, 2005 |
| Replies: 5 Views: 28,693 This is sort of a side issue, but I tend to prefer a static method of Foo being the factory, rather than have a seperate class called, in this case, FooFactory. So, the base class would implement
... |
Forum: C++ Feb 10th, 2005 |
| Replies: 3 Views: 4,304 An escape sequence is something like '\n' for newline or '\t' for tab. An 'illegal' escape sequence is one that the compiler has no idea what to do with, like '\k' or something. That can show up if... |
Forum: C++ Feb 4th, 2005 |
| Replies: 3 Views: 9,855 You might try Google.
'rand' returns an int value in some range. On MSVC it returns a number between 0 and 0x7FFF (32767).
Each time you call it, it returns a different number in a sequence... |
Forum: C++ Feb 3rd, 2005 |
| Replies: 3 Views: 25,826 If it were me, I'd use sprintf() or one of its variants (_snprintf, say).
char display[30];
_snprintf( display, sizeof(display), "%.2f", empMoney );
And forget about scaleing it manually. |
Forum: C++ Feb 2nd, 2005 |
| Replies: 5 Views: 2,996 And GetTickCount() should be something like (depending on the system) the number of 'ticks' since the machine booted. On Windows it it milliseconds since boot, and wraps around every month or two... |
Forum: C++ Feb 2nd, 2005 |
| Replies: 4 Views: 3,488 No need, just rename one of the mains to be something else. |
Forum: C++ Feb 1st, 2005 |
| Replies: 4 Views: 3,488 you have two functions with the name 'main', one in each file. Only one function 'main' can exist in the program. Change one of them.
And, as Naru will tell you if I don't, it should be "int... |
Forum: C++ Jan 27th, 2005 |
| Replies: 16 Views: 14,256 It would be odd to change after a system reset. Structures are often padded to fit the alignment you specified somewhere (or the default). So
struct
{
char a;
int b;
} foo;
If the... |
Forum: C++ Jan 27th, 2005 |
| Replies: 16 Views: 14,256 Naru, was this intentional?
array[i].name[ i ];
shouldn't it be just
array[i].name;
?
Same with array[i].cardtype[ i ]; it should be array[i].cardtype; I think. |
Forum: C++ Jan 24th, 2005 |
| Replies: 3 Views: 10,695 " if (*this == rhs)"
is testing the CONTENTS of the two objects (maybe using an operator); so they may not be the same actuall class, but may contain the same thing. For operator = that is not... |
Forum: C++ Jan 24th, 2005 |
| Replies: 21 Views: 5,990 What is the question? How to pass the pointers without using globals?
in your main you would have, say,
int numberOfPlayers;
int at_bats, singles, doubles, triples, homers;
Then you can... |
Forum: C++ Jan 23rd, 2005 |
| Replies: 3 Views: 2,428 your implementation of int size() has no class before it; it should be
int IntArray::size()
and int IntArray::&operator [] ( int i ) const
does not exist in your class definition (instead... |
Forum: C++ Jan 21st, 2005 |
| Replies: 1 Views: 2,071 Please post the relevent code and tell us what the compile errors ARE. |
Forum: C++ Jan 19th, 2005 |
| Replies: 28 Views: 45,579 keep accessing array elements from 0 until the program segfaults, then back up one and that's your limit. |
Forum: C++ Jan 16th, 2005 |
| Replies: 21 Views: 5,990 Well, for one thing order_chars is declared twice, once with char* and once with char parameters.
It would be helpful to tell us what the compiler actually SAYS rather than "it says there a... |
Forum: C++ Jan 13th, 2005 |
| Replies: 97 Views: 25,702 "Nobody can program in real time with those new languages"
Except for C and careful use of C++, maybe, but you have other issues for real-time stuff as well. Like Windows and Linux getting in... |
Forum: C++ Jan 12th, 2005 |
| Replies: 4 Views: 1,871 So what does this other platform-independent app take as input? Does it support only text files? sockets? All of the above? Seems like that is where you have to start: what does the other app... |
Forum: C++ Jan 12th, 2005 |
| Replies: 4 Views: 1,871 Do you write both apps, or is one a commercial or existing app?
For example, you can chat with Excel via its COM interface, so that decides the question for you.
If you write both apps, maybe... |
Forum: C++ Jan 11th, 2005 |
| Replies: 97 Views: 25,702 This has been a very entertaining discussion!
I love all the "Obviously you have no idea what you are talking about" comments.
I now understand why there is no peace in the Middle East. They... |
Forum: C++ Jan 8th, 2005 |
| Replies: 34 Views: 19,129 What makes you think it doesn't work? What doesn't work? Does it compile? |
Forum: C++ Jan 8th, 2005 |
| Replies: 34 Views: 19,129 That's likely the size of the UNSIGNED long; signed longs that are 32 bits are +/- 2 billion.
on a system with 32-bit longs, then, the range of an UNSIGNED long is 0 ... 0xFFFFFFFF but a signed... |
Forum: C++ Jan 7th, 2005 |
| Replies: 15 Views: 11,927 Hee hee, well, if you insist....
Here's one way:
#define STRING_TO_INT(s1,s2,s3,s4) ((s1 << 24) | (s2 << 16) | (s3 << 8) | s4)
switch (STRING_TO_INT( command[0], command[1], command[2],... |
Forum: C++ Jan 7th, 2005 |
| Replies: 15 Views: 11,927 I think what you are asking (please clarify if I'm wrong) is to map the ascii representation of a string into a number you can use in your switch. This isn't very clean, but can be done. But, there... |
Forum: C++ Jan 6th, 2005 |
| Replies: 1 Views: 17,840 Generally, segmentation faults are because a pointer of yours is either NULL, or points to random memory (probably never initialized to anything), or points to memory that was deleted.
like:
... |
Forum: C++ Jan 6th, 2005 |
| Replies: 9 Views: 13,107 Since Google is a programmer's best friend, a search there yielded a bunch-o-sites (of course), and this one claims to have some source code:
... |
Forum: C++ Jan 6th, 2005 |
| Replies: 8 Views: 2,256 the standard C runtime routines to allocate and free memory do not have a way to tell you how much the OS has free. On Windows you can use GlobalMemoryStatus(), but that talks about total OS memory... |
Forum: C++ Jan 6th, 2005 |
| Replies: 11 Views: 2,564 One often-used choice is a switch statement:
assuming 'command' is one char:
switch (command)
{
case 'w': // the following code is executed when (command == 'w')
... |
Forum: C++ Jan 6th, 2005 |
| Replies: 7 Views: 28,561 Another possability is to export the Excell code to XML, modify it, and pull it back into Excell. This works very well with Excell XP and later, not so well with versions earlier than Excell XP.
... |
Forum: C++ Jan 4th, 2005 |
| Replies: 21 Views: 6,796 In C/C++, another valuable use of pointers is to point to an array of charactors. C doesn't have a string type, and instead you can use an array of char like this:
char name[20];
but to do any... |
Forum: C++ Jan 4th, 2005 |
| Replies: 8 Views: 4,180 Well, the tools aren't very big as I recall, though Spy++ is about all I ever use.
The source is huge, but man is it useful to see what is actually happening when there is a question ("Can I pass... |
Forum: C++ Jan 4th, 2005 |
| Replies: 24 Views: 5,115 You don't say what isn't working, but offhand it looks like 'y' is just getting in the way. There are only x values in s[], so you could use x in your loop and remove y altogether.
I don't see a... |
Forum: C++ Jan 4th, 2005 |
| Replies: 1 Views: 2,603 Sounds interesting. You might search Google for samples that parse the WAV format, because its not all wave form samples, there's other gunk in there too. And, will you match both channels, or... |
Forum: C++ Dec 30th, 2004 |
| Replies: 3 Views: 8,271 I'm not clear on what you are asking. It sounds like you have an input file you are reading and for some set of records on the input file you use a package to create records in an SQL database. Ok,... |
Forum: C++ Dec 29th, 2004 |
| Replies: 7 Views: 19,487 Well, but {Jan, Feb} is not 2 strings, but 2 something elses. Enums, variables, something. If you wanted an array of strings, you'd do something more like this:
char* chararry[12] = { "Jan",... |
Forum: C++ Dec 27th, 2004 |
| Replies: 3 Views: 1,985 On the 'new record' issue, everywhere else you use the ISBN as an index into the file. Yet when you write a new record, you have opened the file in 'append' mode so the write happens at the end of... |
Forum: C++ Dec 20th, 2004 |
| Replies: 7 Views: 2,103 You can make a chair from a stump of wood, too. Or mend socks rather than buying new ones. But, the world has moved on from that. RAM has become 'free' on most systems.
Those of us who work on... |
Forum: C++ Dec 19th, 2004 |
| Replies: 4 Views: 5,534 How about:
get a number
if n > largest then secondLargest = largest, largest = n;
else if n > secondLargest then secondLargest = n;
something along those lines? |
Forum: C++ Dec 18th, 2004 |
| Replies: 3 Views: 3,056 Ya, you need a
current_ptr = current_ptr->next;
in there... |
Forum: C++ Dec 15th, 2004 |
| Replies: 1 Views: 4,815 Shouldn't this:
}while(string[counter] != -1);
be this:
} while (counter != -1);
? |
Forum: C++ Nov 22nd, 2004 |
| Replies: 2 Views: 3,255 You have:
while(!Read.eof()) Read.getline(buffer,300);
cout<<buffer;
Maybe you meant:
while(!Read.eof())
{
Read.getline(buffer,300);
cout<<buffer;
} |