420 Posted Topics

Member Avatar for mauro21pl

[QUOTE=mauro21pl;401898]Hi to all I have a quick question. I am going to fill an array with some inpuit of type char using member function cin.getline. After I fill an array ,I would like to do "for" loop so I need to know what is curently the size of an array. …

Member Avatar for Narue
0
140
Member Avatar for Bladtman242

[QUOTE=ArkM;768879]I have no comments. I think the only good book on C++ is "The C++ Programming Language" by B.Stroustrup ;)...[/QUOTE] Even Stroustrup himself wouldn't say that. There are many really excellent C++ books floating around (of which TCPPPL is just one). If the only book you've ever read on C++ …

Member Avatar for Bladtman242
0
164
Member Avatar for Grimshad

In the latest code you posted, you're using the [b]case[/b] keyword after an [b]if[/b] statement. case is intended to be used in conjunction with [b]switch[/b], and is meaningless on its own. Perhaps you could also show the declaration of your [inlinecode]tfgame[/inlinecode] object, and the declaration for [inlinecode]ToggleWarhead[/inlinecode]

Member Avatar for Grimshad
0
181
Member Avatar for cam875

[QUOTE=cam875;769551]can the name possibly be a number or something, it has to be something that I can increment by 1 or something before I make another atom object, and yes I have used pointers like once or twice but havent found too much use for them yet in my programming, …

Member Avatar for cam875
0
118
Member Avatar for Clockowl

There's a bit of a nasty trick you can perform with arrays and references which can mimic the effect of modifying different data members of a class/struct at runtime. Given a simple struct like the following [CODE=cpp]struct person { std::string forename; std::string surname; std::string telephone; std::string postcode; }; [/CODE]Here, there's …

Member Avatar for Clockowl
0
112
Member Avatar for Dannyo329

There's plenty of ways around the many problems associated with [inlinecode]cin >>[/inlinecode]; IMHO the best way to avoid them is to never use the [b]>>[/b] operator in conjunction with [i]cin[/i] in the first place (unless its really necessary). My personal preference is to keep a separate function which grabs a …

Member Avatar for Bench
0
147
Member Avatar for rtmarch

You're presumably trying to call your function called [inlinecode]search()[/inlinecode] but you also have a local variable called search too. The compiler doesn't understand, and thinks you're referring to that variable. I'd suggest you call your variable something else instead

Member Avatar for Bench
0
85
Member Avatar for Joncamp

Found in about 15 seconds in Sun's java documentation... [url]http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html[/url]

Member Avatar for stultuske
0
102
Member Avatar for sid78669

It sounds as if you need to set up some accessor/modifier methods within your account class, rather than attempting to access them directly from your bank member functions. private data members of a class can only be directly accessed from other members of that same class

Member Avatar for sid78669
0
213
Member Avatar for chchiu

Noone will spoonfeed you any solutions. have a good attempt at the problem for yourself and come back if you get stuck on anything along with a description of whatever it is you need help with, and the code you've tried so far.

Member Avatar for mrboolf
0
127
Member Avatar for abhijitm

Look very closely at this line [inlinecode]dynarray(const [b]dynarrray[/b] &ob);[/inlinecode] I believe you probably meant to type [b][i]dynarray[/i][/b] instead

Member Avatar for abhijitm
0
147
Member Avatar for atish00

Presumably you're already passing the array in as a parameter, so returning it is a little pointless (The original will be modified anyway, since arrays are always passed by-pointer to a function). Arrays aren't copyable, so they must be returned by-pointer. The syntax gets a bit messy, so you ought …

Member Avatar for atish00
0
271
Member Avatar for chanderk

A pointer is an object which represents an address in memory. A reference is just a 'nickname' or 'alias' for an existing object. I'm not going to go into any further detail since the nature of the question sounds a little bit like 'please do my homework for me'. Have …

Member Avatar for Ancient Dragon
0
139
Member Avatar for NekoGráfico

A few comments - When handling dynamically allocated memory in C++, you should use the [b]new[/b] operator. Malloc is bad, since all it does is allocate memory on the heap - if you're creating an object of a particular class/struct, then that object will be uninitialised. - Keep in mind …

Member Avatar for NekoGráfico
0
106
Member Avatar for neverness

You mentioned that you attempted a return type of [inlinecode]Tree<T>::Node[/inlinecode], However, that's not sufficient for the compiler to take your word for it that Node is indeed a type identifier and not something else. The issue is that Tree<T> is an incomplete type, where Tree::Node could be absolutely [u]anything[/u] depending …

Member Avatar for neverness
0
254
Member Avatar for np2100

I'd be willing to bet that the vast majority of C++ developers rarely touch the Windows API directly. Even if you limit that group to just those who even develop applications for Windows platforms, much of the time the Windows GUI code is likely to be wrapped up in several …

Member Avatar for yap.nice
0
133
Member Avatar for NickyU

Why don't you try it for yourself and find out? If the compiler doesn't complain, then you know its ok The only point where your compiler [i]might[/i] produce an error, is if you attempt to compile under C++, where [b]true[/b] and [b]false[/b] are reserved words which cannot be reused elsewhere. …

Member Avatar for Bench
0
120
Member Avatar for Code Shark

I'm not sure what language that is, but its not C or C++, unless the contents of "resource.h" happen to be an extremely nasty set of macros and #define statements. If we knew what was inside resource.h. we might be able to give a better answer

Member Avatar for TheBeast32
0
329
Member Avatar for Narue

Nothing serious, just a couple of nitpicks - [QUOTE=JRM;379611][code]#include <iostream> #include <math.h> [/CODE][/QUOTE]Since this is C++, change that to [INLINECODE]#include <cmath>[/INLINECODE] [QUOTE][CODE]unsigned long extract_digits ( unsigned long x, size_t n, size_t i ) { int z=0, c=x; [/CODE][/QUOTE] 'x' is an unsigned long - don't take the risk that int …

Member Avatar for ivailosp
1
680
Member Avatar for Emperor456

Yes, I'm sure you'll find many, many people willing to recreate, for free, a game which took a team of professional developers tens of thousands of man hours to produce.... Alternatively, why don't you start out with "Hello, world" and move on from there..

Member Avatar for Tsuruya-san
0
324
Member Avatar for cynthann

I can think of a better way. if you wish to calculate the sum of all numbers in a range, the formula is [INLINECODE]n( (First+Last)/2 )[/INLINECODE] in your case, the first number is always going to be 2 ... 'n' is the "number of numbers" in the range.. eg, from …

Member Avatar for ruhneb03
0
161
Member Avatar for tonylamb

The only problem I can see with your code is that eit2 will overflow, being one step in front of eit1 each time. I can't see anything which looks like it should give a compiler error. Could you paste a more complete example of your code, since the actual problem …

Member Avatar for tonylamb
0
958
Member Avatar for Sgt. Pepper

[QUOTE=Sgt. Pepper;531537]I bought the book C++ Primer Plus [url]http://www.amazon.com/C%2B%2B-Primer-Plus-Stephen-Prata/dp/0672326973/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1202680271&sr=8-1[/url] because i plan on learning the C++ language, but i can't really understand what it is trying to say when it is suggesting compilers. Can anyone give their feedback on the best compilers for beginners? [/QUOTE]I assume you're after an IDE …

Member Avatar for Sgt. Pepper
0
200
Member Avatar for atish00

Assuming you're supposed to write your own, rather than use the standard C++ [inlinecode]sort[/inlinecode] function, You'll need to implement a sort algorithm. a bubble sort or a selection sort should be fairly easy to write. You'll find pseudocode for these here [url]http://en.wikipedia.org/wiki/Bubble_sort[/url] [url]http://en.wikipedia.org/wiki/Selection_sort[/url]

Member Avatar for Lerner
0
146
Member Avatar for >shadow<
Member Avatar for dougy83

The page appears to be over 10 years old, and the information probably older than that. Standard C++ does not have a class called ostrstream, and, to my knowledge, the standard C++ [i]stringstream[/i] facility does not leak.

Member Avatar for dougy83
0
2K
Member Avatar for TimeIsCyclical

The alternative, using the <map> library, if you'd prefer to give the orders a 'Key' value identifier [CODE=CPP]#include <map> /* ... */ std::map< std::string, order > the_orders; order my_order; the_orders.insert( std::make_pair( "order1234", my_order) ); [/CODE] Although, the vector/deque solution posted by Salem is simpler IMHO. A little more on maps …

Member Avatar for Bench
0
99
Member Avatar for driplet

[QUOTE=elite1986;494754] >main() Why shoud i write when i do not need it ,when i need to write then i write. >return 0; Same thing . [/QUOTE] main returns an int because the standard says it returns an int. if you omit the [b]int[/b] return type from main then some compilers …

Member Avatar for Narue
0
455
Member Avatar for vs49688

I think he asked for 250 miliseconds didn't he? not 25? Anyway, it shouldn't matter, because there's no guarantee that CLOCKS_PER_SEC is equal to 1000 (I believe on POSIX systems its defined as 1000000) I also think its a bad idea to use the name 'sleep' too, since its a …

Member Avatar for Ancient Dragon
0
96
Member Avatar for ithelp

If you were asked in another interview, which words would you remove from the English language, and why, how might you answer? Then ask yourself what you think people who spoke the language would do after those words had been "removed" ?

Member Avatar for Salem
0
116
Member Avatar for balla4eva33

[QUOTE=Ancient Dragon;493718]Huh? I assume DMA means Direct Memory Address. How does that relate to the discussion of this thread ? BTW DMA is not possible with any 32-bit compiler unless writing a kernel-mode device driver.[/QUOTE] I think he means 'Dynamic Memory Allocation' - I could be wrong though. Either way, …

Member Avatar for Ancient Dragon
0
110
Member Avatar for Queue

I could be mistaken, though I believe that the STL sorted containers expect a type with a valid [b]operator<[/b]. If the type doesn't provide one, then overloaded constructor(s) will take an additional parameter in the form of a compare function, or a function object which overloads [b]operator()[/b] instead. Since you …

Member Avatar for Queue
0
214
Member Avatar for balla4eva33

The best tip I can think of with regard to writing templated code, is to write a non-template version first. Then you can be sure that your program is correct for one type (such as int), and that you're happy with the design of your class(es). Afterwards, create a generic …

Member Avatar for balla4eva33
0
194
Member Avatar for roxanne14

If you're able to split each 'word' into separate strings, then you're already half way there use the [inlinecode]toupper[/inlinecode] function on the first character of that word, to generate the uppercase equivalent of that character (If an uppercase equivalent is available). [CODE=CPP] word[0] = toupper( word[0] ); [/CODE] This won't …

Member Avatar for Tight_Coder_Ex
0
554
Member Avatar for Thunder2k4

The [inlinecode]>>[/inlinecode] operator skips over whitespace automatically. One alternative could be to capture each line of input from the file individually as a string, using the getline function. [CODE=CPP]std::string my_string; while( std::getline( input, my_string ) ) { //TODO: Counting } [/CODE]

Member Avatar for Thunder2k4
0
304
Member Avatar for DoctorBob

There's no such thing as a "Best" sorting algorithm. Depending on the amount of data you're holding, and how ordered the data is to start with, one algorithm may be better than the other in different situations. If you wanted to test them out against each another, you could devise …

Member Avatar for DoctorBob
0
118
Member Avatar for sneha_venky
Member Avatar for vijayan121
0
218
Member Avatar for nquaoser

I can see why that is a controversial solution. it would be very easy to mis-read the intention of that code. The least you could do would be to provide brackets around the identifier and post-increment :) ie [CODE] while( *(outstr++) = *(instr++) ) [/CODE]

Member Avatar for n.aggel
0
338
Member Avatar for AllenN

Maybe i'm unclear of the question.. but a number is just a number - you can use it to represent whatever you want. There's nothing particulary special about your 32 bit max value.. some systems can handle more, other systems can handle less, although, if you get hold of a …

Member Avatar for AllenN
0
208
Member Avatar for Duki

[QUOTE=Duki;428892] at this line [inlinecode]pizza.set ( x , y , a[7] , i ) ;[/inlinecode] [/QUOTE]a[7] is an element in your array (Also - if your array is only 7 elements in size, then valid elements are indexed 0-6, so you're accessing one-past-the-end.) try this instead [inlinecode]pizza.set ( x , …

Member Avatar for Dave Sinkula
0
307
Member Avatar for tendyhk

One thing I'd like to mention about the psuedocode comment - its unusual to specify data types in pseudocode - normally, details like that are left anonymous, concentrating on the high-level flow of the program (The reason being that data types are an irrelevent detail from an algorithm point of …

Member Avatar for ndeniche
-1
142
Member Avatar for vijayan121

[QUOTE=Hamrick;427973]I appreciate your useful help and links, but I don't think I'm smart enough to understand template metaprogramming. Even the simple rebind you showed me before doesn't make any sense...[/QUOTE] its a rather elaborate complicated example of template metaprogramming for a newbie IMHO. Try this as a simpler one :) …

Member Avatar for Bench
1
451
Member Avatar for bops

That would probably be a password cracker's dream come true. Seriously, do you really think there's going to be an easy way to access encrypted Windows passwords like that? (I am aware of programs which do this, but only by re-starting the computer and using a linux boot CD to …

Member Avatar for Ancient Dragon
0
105
Member Avatar for Ashu@sym

AFAIK the C and C++ languages don't define the term 'handle', so its use can vary according to context. In addition to the usage as described in Hamrick's link, some texts use 'handle' to describe C++ [i]References[/i] .. in this context, 'handle' is a synonym for 'alias' or 'nickname'.

Member Avatar for SpS
0
259
Member Avatar for Duki

[QUOTE=cscgal;425735]I haven't taken a math class in many, many years, but from what I can recall, you rotate a point by drawing a vector starting at the origin and passing through the point, and then rotate that vector 90 degrees, in this case.[/QUOTE] Yes that's right, but it assumes you're …

Member Avatar for Duki
0
225
Member Avatar for Ken JS

[QUOTE=Ken JS;425929]anybody know how to see this??? (23,12,7) binary code???[/QUOTE] Representing integers as a binary number..? if not, would you be a bit more specific? Here's one way, using a bitset [CODE=CPP]#include <iostream> #include <bitset> int main() { //bitset with 8 bits typedef std::bitset<8> bits_8; std::cout << bits_8(27) << '\n' …

Member Avatar for Dave Sinkula
0
138
Member Avatar for joydsouza90

Are you talking about C++ strings or C-style char arrays? (I assume you're talking about char arrays, based on your post) What do you mean by "completely empty"? You can make a C++ string blank by doing this [CODE=CPP]std::string name = "hello"; std::cout << name; //Assign 'name' a blank string …

Member Avatar for WaltP
0
9K
Member Avatar for nayr055

the problem might be easier for you to see if you used a more consistant indenting style. Here it is, reformatted (Courtesy of MSVC++'s auto-format tool): [CODE=CPP]int main() { clrscr(); int one, two, three,x; char choice; while (choice != 'e') { cout<<"\nWELCOME! To access my calculator, please follow the instructions …

Member Avatar for Hamrick
0
188
Member Avatar for NycNessyness

[QUOTE] [CODE] char studentgrade; char lettergrade[1]; char A[1]; [/CODE] [/QUOTE] There's no point having an array of one character.. and there's no point storing seperate variables for each grade, you could just do this (note the single-quote marks) [CODE=C]if (studentgrade > 90) { lettergrade = 'A'; } [/CODE] You're on …

Member Avatar for Bench
0
125
Member Avatar for patrick210

if you want to retrieve an entire line from a stream (such as cin, or a file), then you need the getline function [CODE=CPP] string temp; getline( cin, temp ); [/CODE] Edit- by the way, if you use [inlinecode] cin >> [/inlinecode] you need to be careful, because it comes …

Member Avatar for Bench
0
135

The End.