278 Posted Topics

Member Avatar for eng hassan

No one is going to design this for you since you don't show us that you have made any effort at all to think about the problem (other than how to write your question and copy/paste the problem description). You know that you want to use OOP concepts to write …

Member Avatar for eng hassan
0
118
Member Avatar for frag

We don't know how your teacher grades.. and what you have learned so far that you could apply. So saying yes it is correct would be a bold statement. But this is indeed a data structure that holds the information listed. However you forgot to initialize the 'city' part of …

Member Avatar for JohnSmith12
0
133
Member Avatar for tundra010

Are you calling your destructor function explicitly? If so.. you probably shouldn't ;)

Member Avatar for tundra010
0
108
Member Avatar for zyky

Are you compiling a 'debug' build? If so, you should get an ASSERT much earlier. Look at your aggiungi function (btw, why are you mixing english and other-language variable/function names? It can become very confusing). In this aggiungi function, why are you creating r2 on the heap(e.g. why are you …

Member Avatar for zyky
0
196
Member Avatar for rowley4

I think it's best you try and explain what you are trying to accomplish. At the moment the use of strncpy isn't what it's intended for. It seems to me you have a pollution_day array that you're trying to fill in the set_pollution function... but it's unclear what you want …

Member Avatar for daviddoria
0
136
Member Avatar for Ral78

A much better (C++) solution would be to move away from C-Style arrays and use a container class like 'vector'. This will also allow you to use std algorithms like std::sort to sort the vector

Member Avatar for Ral78
0
150
Member Avatar for vanalex
Member Avatar for vanalex
0
226
Member Avatar for bklearner

[QUOTE=bklearner;1235604]I am not sure how to get the input from the commandline from the user.[/QUOTE] Do you want the user to type something in the console? In that case you get 'get' this input with "cin", it works simmilarly to cout. If you want a user to start your application …

Member Avatar for NathanOliver
0
259
Member Avatar for Sandhya212

stringstreams are a much cleaner solution than dirty C sprintf functions and should definitely be preferred when writing C++ code

Member Avatar for Sandhya212
0
221
Member Avatar for ferenczi

There definitely is, and it is a big part of the power of C++. What you're looking for are called "templates", there are a lot of references about it on Google but of course if something is unclear you can always post here and someone will explain ;) Edit: You …

Member Avatar for thelamb
0
126
Member Avatar for vadalaz

First of all: Do you understand why there is only one beep and after that never again? Secondly, let's think about your problem. You have an X number of objects(windows) and you want them to perform an action only once. So for each of these objects you can store a …

Member Avatar for thelamb
0
286
Member Avatar for CarleneGriffith

First of all, you should use code tags, no one is going to read through your code like this. Secondly, if you've written this code then the errors should make perfect sense. Did you even check the lines where the errors occur? If so, you need to be more precise …

Member Avatar for CarleneGriffith
0
139
Member Avatar for Shaida

[code] #include<iostream.h> void hi(void) void name(void) int main() { [/code] First of all, you should include <iostream>, not <iostream.h> Secondly, you should tell us in what line the error is.. or at least copy/paste the exact error. But I tried to compile your code and the error is in the …

Member Avatar for Shaida
0
2K
Member Avatar for pato wlmc

You're confusing compilers and IDE's. Microsoft Visual Studio is an IDE, the code is compiled with the Microsoft C++ compiler. A lot of people have different opinions about IDE's, you're just going to have to try one for yourself and see if you like it, I don't think there is …

Member Avatar for thelamb
0
228
Member Avatar for Dyed Purple

Your do..while statemen is wrong (so you are getting the error at line 15 I guess, not at 9 where you are also using cin). This indicates that cin itself isn't the problem, but something closely before the line where the error is. A do/while is written like: [code=cpp] do …

Member Avatar for thelamb
0
230
Member Avatar for daviddoria

I don't really understand what your plan is... but if I am correct this should be equivalent and clean: [code=cpp] class PersonClass { public: std::string Name; virtual void GoToWork(){}; // Or GoToJob, whatever suits you }; class LawyerClass : public PersonClass { public: void GoToWork(){ cout << "Going to Court"; …

Member Avatar for daviddoria
0
71
Member Avatar for toitoi

This is the correct (and beautiful) behavior. When you access a member function through a reference or a pointer of a base class, the derived class's function will be called. This allows you for instance to store a container of BaseClass* and store many different DerivedClass objects, without having to …

Member Avatar for toitoi
2
112
Member Avatar for John Linux

Your result is compiler (option) specific. You're probably compiling with "Optimize for speed (O2)", if you remove this option you will probably not see EQUAL being printed (at least not with my compiler). So try to compile with different options, and print the addresses of a and b ;). In …

Member Avatar for thelamb
0
140
Member Avatar for Jack_1

First of all, use CODE TAGS when you are pasting code! Secondly, you are never calling your function. Finally, look at the loop that you have in your function. You start b at 0, and you want the loop to run only if b is greater than 1 and less …

Member Avatar for NP-complete
-1
151
Member Avatar for psdao1102

And let's explain why: On line 44, you call searchArray with items and itemA. items and itemA both have different types, but your searchArray expects them to be the same type (both of type 'T'). If you apply firstPerson's fix, 'answer' and 'index' can be of different, or the same …

Member Avatar for thelamb
0
83
Member Avatar for codecx

[code=cpp] void main() [/code] Are you sure this is correct? If so.. why? your enemy variable is a local, automatic variable. This means it will be destructed when it goes out of scope(do you know what a scope is?). If you wish to delete the variable at some 'random' point …

Member Avatar for codecx
0
155
Member Avatar for Brokenpwn

You should learn the basics of C/C++ before you attempt to make a game cheat/hack. This is simply copy/pasting code and then copy/pasting the error here. Btw, if you read the errors it tells you exactly what to do.

Member Avatar for Brokenpwn
-1
458
Member Avatar for BLKelsey

You are close actually.. it's really not that horrible. Look at average in the .h file, and then at average in the .cpp file. Now think of it from the compiler perspective, it sees int average( int something ); in the header file, so a function that takes an int …

Member Avatar for BLKelsey
0
270
Member Avatar for Atlanticspace

You declare fgetline as a member function of the UTAevent class. Except, when you define it you do not tell the compiler that the definition is part of the UTAevent class: [code=cpp]int fgetline(FILE *fp, char s[], int lim) { // ... } [/code] Look at the other functions declared in …

Member Avatar for Atlanticspace
0
165
Member Avatar for gendler.max

Don't you already do it with 'Equipment' ? You have several options on how to store the Hero object in the vector, you can store it like you store the "String" in Equipment, or you can decide to store a pointer to a Hero object (Hero*) instead.. it depends on …

Member Avatar for gendler.max
0
137
Member Avatar for shazzy99

I didn't look through your whole code, but what you do with the thread makes no sense. You create the thread, and then wait for it to complete. Why is this needed? E.g. why did you chose to use a thread rather than just call the function directly. Anyway.. to …

Member Avatar for shazzy99
0
318
Member Avatar for HoboConductor

You have bigger problems than this... void main() <-- really? char *delim = ";"; <-- You need to learn what a pointer is, and how to use them, what you do here should ring a million alarm bells. The error you are getting is because you are trying to assign …

Member Avatar for Fbody
0
114
Member Avatar for 3cats

Whenever you call a function, you do not need to include the argument's datatypes. For instance: [code=cpp] // Function that returns nothing and takes 1 int as argument void myFunction( int myInt ) { cout << "Your number: " << myInt << "\n"; } int main() { int myInt = …

Member Avatar for 3cats
0
223
Member Avatar for dylan9

Well that's all nice and dandy, but no one is going to read through your source if you just ignore the rules this board has (How did you even miss the fact that you should use code tags?). "I need a code in string as much as possible but if …

Member Avatar for abhimanipal
0
2K
Member Avatar for empror9

By using your brain and thinking about the problem rather than asking how it is done. As with any problem, try to break it up into smaller, easier pieces. There is a string and you want to count the number of a's... in the real world, how would you do …

Member Avatar for batchprogram
0
121
Member Avatar for nerdinator

Encryption is not a matter of "read a book and you can write a quality encryption scheme" there are extensive subjects to the matter. It is always dangerous as a non-encryption-expert to create a encryption scheme, just use an existing encryption library, and don't say it will be less secure …

Member Avatar for thelamb
0
96
Member Avatar for Expora

Check your spelling of initRendering function. Also, the drawscene function is spelled with a lower-case s while you try to call it with an upper-case S

Member Avatar for Expora
0
101
Member Avatar for ranvi

Can you explain why you want to "hide" the structure from the SetInt and SetString functions? This is a really dirty trick and should hardly ever be necessary in C++...

Member Avatar for Salem
0
455
Member Avatar for bigdawgg

That's not a question, that's "Can someone please do my homework". Which unfortunately no one is going to do for you. So, as with many problems, the first step is: break it up in parts. -> Do you know how to open a file? -> Do you know how to …

Member Avatar for jwenting
0
191
Member Avatar for gregarion

[QUOTE=gregarion;1183538]Sorry, i pasted the copy i edited. should be while .[/QUOTE] Even that will not compile... Fixing this while loop and running the program gives me the 'expected' 600 output, so I'm not sure what you're doing...(It is impossible to get 400 with CD as input). [code] Enter the roman …

Member Avatar for gregarion
0
109
Member Avatar for metdos

You have already done it... Look at how you declare your 'request': [code]Request *request=new Request();[/code] So 'request' is now allocated on the heap.. means you are responsible for cleaning it up (delete request; somewhere in the code). Then, you say.. ok I want 'request' to point to a LoginRequest. [code]LoginRequest …

Member Avatar for metdos
0
291
Member Avatar for Falmarri

I used boost in a project where I needed regex. It is distributed as a library though so you need to link to it. More info here: [url]http://www.boost.org/doc/libs/release/libs/regex/[/url] With this library, you can put ( ) around the part that you want to return as a match. So e.g.: Message: …

Member Avatar for Falmarri
1
144
Member Avatar for merse

You can create a map of "Specific Object" pointers. E.g.: [code=cpp] class CMemoryMap { public: void newObj( const CObject& myObject ) { m_mMemoryMap.insert( std::pair<CObject*, some_data>( &myObject, some_data ) ); } void delObj( const CObject& myObject ) { map_iterator = m_mMemoryMap.find( myObject ); m_mMemoryMap.erase( map_iterator ); } private: map<CObject*, some_data> m_mMemoryMap; …

Member Avatar for merse
0
118
Member Avatar for dshiells

First of all, use CODE TAGS when you post code on this forum (not sure how you missed that with all of the information about it jumping in your eyes). You got the general idea of a mutex right... but there are some things you should note. First of all: …

Member Avatar for thelamb
0
1K
Member Avatar for Coder2009

No one is going to do your homework coder2009, but nice try. If you have a problem with these questions.. think further and ask more specific what exactly you don't understand. For example in the first question.. do you know what a static cast is? etc. If you show that …

Member Avatar for Stefano Mtangoo
0
112
Member Avatar for MJaske

You can't get root2 to output.... are you sure that you are entering values for A, B, C etc. so that Discriminant is 0? As when it's > 0 only Root1 is printed of course. Also have a look at how you check if 'A' is non-zero. What happens if …

Member Avatar for MJaske
0
199
Member Avatar for V0ldemort

Think about what an LPCWSTRING is... The example 2 lines what you give does not really make sense to do, it may help if you give some more information on what you want to do. Most importantly: Where does 'name' come from

Member Avatar for thelamb
0
60
Member Avatar for rahul8590

Aren't there any examples in your OS-course book? I had an OS course(outside of my normal curriculum as I study mechanical engineering) too this semester, which included a 'lab' where we were given the task to write a multi threaded assignment. I would suggest using the 'pthread' library, especially in …

Member Avatar for rahul8590
1
766
Member Avatar for joshbeebe

It's not possible to 'convert' a string to a class with the same name as the value of the string. What you can do is: - Use a switch case, it is much more friendly as 100 if statements. - Create a hash table where you can look up the …

Member Avatar for Bench
0
302
Member Avatar for Laxman_Cit

This is a typical answer that can be found through 2 seconds of googling. [url]http://www.cplusplus.com/reference/clibrary/cstdlib/system/[/url] Though I generally think calling system() is a bad design, the overhead is massive and mostly there are much better alternatives.

Member Avatar for thelamb
-2
96
Member Avatar for daeuse

There is a thread about clearing buffers as a sticky somewhere. Think about the two differences in C++ with regard to 'assigning a value' and 'comparing two values'. In the do..while loop you want to compare DoItAgain with 'true'. But in your code you assign DoItAgain the value 'true' (By …

Member Avatar for daeuse
0
215
Member Avatar for qwertymk

I don't think this is possible, as malloc is just allocating a block of memory for you, it won't actually put anything in. Could you tell us why you really have to do this? It's often better to ask how to do something than 'why doesn't my implementation work'.

Member Avatar for Narue
0
147
Member Avatar for nedsnurb

So now you expect us to read the whole code line by line, or compile it ourselves to find the error that you could just post in 2 seconds?

Member Avatar for UberJoker
0
109
Member Avatar for Japus

You have to delete it at a point where you can guarantee that after the delete you won't access it anymore. This can be at the end of an application, in the destructor of a class or just somewhere in a function that prints the variable and is then done …

Member Avatar for thelamb
0
2K
Member Avatar for axed

Instead of answering your question(which is not possible with the code you provided) let's take back a step and ask yourself why do you hand over a char*? If, for some obscure reason, it is needed then Dave Sinkula's question should be answered. What .c_str() does, is 'convert' the string …

Member Avatar for thelamb
0
130

The End.