2,898 Posted Topics

Member Avatar for Xploit_

Instead of bothering yourself with doing copies of backup files with the tilde mark. I would suggest you just use a subversion control system. I recommend [URL="http://git-scm.com/"]Git[/URL]. At any time, you can retrieve the entire history of the modifications to any of your source files ("diff" style). That's very easy …

Member Avatar for nezachem
0
354
Member Avatar for senergy

>>#2 You cannot use the == operator for comparing C-strings (arrays of chars), this will only compare the pointer values. To compare the actual C-strings, you need to use the [URL="http://www.cplusplus.com/reference/clibrary/cstring/strcmp/"]strcmp[/URL] function. For the rest, I don't understand the questions or what you want.

Member Avatar for caut_baia
0
361
Member Avatar for estelion

Just make the handler for the click button event in the Interface class, and then call a function of the DAQCycle class, and pass it the "this" pointer of the Interface object.

Member Avatar for mike_2000_17
0
148
Member Avatar for hqt

This: [CODE] l.pHead=p.pNext; p.pNext=NULL; Thus, l.pHead=NULL; [/CODE] is wrong. You are thinking about the = operator as if it was like in mathematics. When you write "a = b" in C++ (and in almost any programming language), it means that you copy the value of b and assign it to …

Member Avatar for hqt
0
201
Member Avatar for Labdabeta

This is a question that comes up from time to time on forums on C++. And, I'm convinced now that there is no way to do this. I hope I'm wrong, but I think there is little chance.

Member Avatar for mike_2000_17
1
182
Member Avatar for fatalaccidents
Member Avatar for fatalaccidents
0
107
Member Avatar for xenhancd

To store the prices as doubles, just make them doubles. Declare your price pointer as: [CODE] double * price; [/CODE] And allocate an array of doubles: [CODE] price= new double[items]; [/CODE] You don't have to change anything else (that I can see).

Member Avatar for mike_2000_17
0
235
Member Avatar for mridontknow

If your problem corresponds to iamthwee's interpretation, then his solution is appropriate. If your problem is that you want to create a vector of arbitrary size where each element is one of the four color-strings, picked at random. Then, a simple solution is to map each color to a number …

Member Avatar for mrnutty
0
2K
Member Avatar for adam25

Well, pretty much everywhere in the code, you use a single < where you need two (outputting with streams). That will fix your problem. And you also need to #include <cstring> to get the strlen function.

Member Avatar for adam25
0
353
Member Avatar for IndianaRonaldo

>> I have not given a size to the vector.Could it be because of that? Well, if your vectors are empty, how could you expect to be able to access elements of them? I think people reading your example assumed it was not real code, just an example of the …

Member Avatar for IndianaRonaldo
0
175
Member Avatar for Jason Giggs

What Narue says is entirely correct. >>WHy does the loop terminate after 13 iterations? Your stack-frame will look like this: 8 bytes for the char-array (ca) (aligned at 4 bytes, since it needs 5 bytes, it will take up 8 bytes as the smallest multiple of 4 bytes), and 4 …

Member Avatar for mike_2000_17
0
96
Member Avatar for mrnutty

Or maybe something along the lines of: [CODE] #include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream infile("input.txt"); ofstream outfile("output.txt"); int value; while(infile >> value) { char mod_val = (--value) % 52; outfile << string(value / 52 + 1, (mod_val < 26 ? mod_val + 'a' …

Member Avatar for iamthwee
1
151
Member Avatar for n8thatsme

Don't bump a three year old thread to ask an unrelated question. If you can't find the answer to your question by looking on Daniweb or on the web at large, then create a new thread for your question. And to answer, to convert a string to a float, you …

Member Avatar for mike_2000_17
1
4K
Member Avatar for empror9

Well, first, your error about printing the object's content is easily solved. Your function "getVehicleType" prints the values already, so you just need to call it, don't insert it into a << operator statement, just call it: [CODE] //cout <<"id "<< vehicles[i]->getVehicleType() <<endl; //ERROR! vehicles[i]->getVehicleType(); //OK! [/CODE] Now, about the …

Member Avatar for mike_2000_17
0
194
Member Avatar for Mast3r67

As for the libraries, I would recommend to use well-established cross-platform libraries. For your purposes, SDL and/or OpenGL are candidates of choice. Start with SDL and add OpenGL when you want to take your graphics one step further. Programming a graphics computer game is a lot different from simple console …

Member Avatar for mike_2000_17
0
184
Member Avatar for Daita

In the simplest possible way, it means: Dear mister compiler, In this place (or scope), I would like to be [ICODE]using[/ICODE] this [ICODE]namespace[/ICODE] that they call [ICODE]std[/ICODE]. This would really help me because I won't have to qualify everything with [ICODE]std::[/ICODE] in the remainder of this scope. Thank you. And …

Member Avatar for HASHMI007
0
101
Member Avatar for reallyslick

You will find the reference on std::map [URL="http://www.cplusplus.com/reference/stl/map/"]here[/URL]. A simple example that basically fits your problem is this: [CODE] #include <iostream> #include <string> #include <map> using namespace std; int main() { map<string,string> tags; //create the list of tags: tags["-color"] = "c"; tags["-weight"] = "w"; tags["-size"] = "s"; //... while(true) { …

Member Avatar for reallyslick
0
189
Member Avatar for eoop.org

[CODE] $ sudo apt-get install linux-source [/CODE] From a Linux terminal, of course.

Member Avatar for eoop.org
0
133
Member Avatar for ztdep

A forward-declaration simply announces that a class with that name will be declared later. But to be able to use any of the members of the class (including constructor/destructor or any data members or member functions), the compiler has to have seen the declaration of the class, not just its …

Member Avatar for ztdep
0
258
Member Avatar for ztdep

You need to be consistent with the const-qualifier, either you have a const function that returns a const reference or you have a non-const function that return a non-const reference, but usually, you can just do both: [CODE] const vector<double>& getDensity() const {return density;} vector<double>& getDensity() {return density;} [/CODE] The …

Member Avatar for mike_2000_17
0
8K
Member Avatar for ztdep

This "pre-declared class", as you call it, is what programmers call a "forward-declaration". A forward-declaration is useful when you need two classes to depend on each other (which would otherwise not be possible). Here is a simple example: [CODE] struct DogOwner { Dog fido; }; struct Dog { DogOwner master; …

Member Avatar for ztdep
0
286
Member Avatar for tedman102

The operation: [CODE]if(prompt2 == "ADD", "ADDITION", "+", "PLUS")[/CODE] will not do what you expect. It will always evaluate to true, regardless of the value of prompt2. This is because it uses the comma operator. The comma operator has the effect of evaluating each elements between commas and return the value …

Member Avatar for tedman102
0
430
Member Avatar for siaswar

>>How can I be a programmer who can understand the codes and writes neat and clean code. You learn by experience, like anything else, practice makes perfect. If you are comfortable with the syntax of a language and the general logic of programming, then the next step is usually to …

Member Avatar for katmai539
0
223
Member Avatar for Jsplinter

add the serialization library to the linking, directly. Not just under library directories, but also as a library to be linked. Find the boost_serialization library (either libboost_serialization_..a or boost_serialization...lib). Boost has some automatic linking of some required libraries, but this system only works for some compilers (e.g. MSVC) but not …

Member Avatar for pseudorandom21
0
451
Member Avatar for Kerlix

You need to #include <string>. The problem is because iostream declares the string class via some inclusions under-the-hood, but it does not include the << operator for the string. At least, on some implementations, this is what happens, on others, it includes both the string class and its << operator, …

Member Avatar for Caligulaminus
0
312
Member Avatar for Peter4n31

You have fell pray to the [URL="http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14"]"static initialization order fiasco"[/URL]. Read the linked article, and you will understand the problem and read about the solution.

Member Avatar for Peter4n31
0
146
Member Avatar for rajatchak

Well, you are going to need to do simple input/output with the user and with a file. For user input/output on the console, you will need <[URL="http://www.cplusplus.com/reference/iostream/"]iostream[/URL]>, with cout for output and cin for input. See [URL="http://www.cplusplus.com/doc/tutorial/basic_io/"]this tutorial[/URL]. Then, you will need to use [URL="http://www.cplusplus.com/reference/string/string/"]std::string[/URL] to manipulate strings, to be …

Member Avatar for rajatchak
0
218
Member Avatar for milan2011

>>"to use a hash table to sort" I'm not an expert on hashing, but this statement seems to make little sense to me. Hash tables are rarely used to sort anything (which requires a hash function that respects the ordering of the keys, which typically makes it very difficult to …

Member Avatar for m4ster_r0shi
0
682
Member Avatar for agogte20

I do agree that C and C++ are two distinct languages and, in general, you can just learn one (C++) directly. It's not like C is a stepping stone to learning C++. If you want to learn C++, then you don't need to learn C first, that's just a waste …

Member Avatar for mike_2000_17
0
132
Member Avatar for dashure

In your CManager class, you should have a data member like: [CODE] std::vector<CWorker> m_Workers; [/CODE] In your CWorker, as suggested, you should have a constructor like: [CODE] class CWorker { //... public: CWorker(const char* aName,int aSalary = 0) { m_wName = aName; m_wSalary = aSalary; }; [/CODE] And, your addWorker …

Member Avatar for laosland
0
222
Member Avatar for ktsangop

This code: [CODE] myclass Object("some_file.xml"); if (Object.error_val == -1) delete Object; [/CODE] Is invalid. You cannot "delete" things that are allocated on the stack. "delete" can only be used to delete things that were allocated with "new", as so: [CODE] myclass* Object = new myclass("some_file.xml"); if (Object->error_val == -1) delete …

Member Avatar for ktsangop
0
962
Member Avatar for fsefsef23

Is it "stack<int>" or an array? Because stack<int> is a standard container (adaptor), named [URL="http://www.cplusplus.com/reference/stl/stack/"]std::stack[/URL]. It is very possible that the author sloppily said it is an array, because many C++ programmers (including myself) will often forget that the general term "array" (which can mean any kind of homogeneous data-set) …

Member Avatar for fsefsef23
0
266
Member Avatar for sairus

I think that the first thing to do is to get a container for all the unique words that describe numbers (not compounded). If in English, that's not very hard or very many. The unique numbers run from 0 to 19, then 20-30-40..90 and 100-1000-1000000.., everything else is a compounded …

Member Avatar for WaltP
0
1K
Member Avatar for evilguyme

You have a semi-colon at the end of line 88, which should not be there. Because this is how the compiler interprets things: [CODE] void myFunction(); //declaration of "myFunction" void myFunction() //definition of "myFunction" { //... }; void myFunction(); //declaration of "myFunction" { //ERROR: what is this { ? You …

Member Avatar for mike_2000_17
0
288
Member Avatar for Labdabeta

The error comes from lines 105 and 114, you should not multiply the numt by 3. The "count" given to the glDrawArrays is the number of vertices to draw, so it should be numt. As so: [CODE] glDrawArrays(GL_TRIANGLES, 0, numt); [/CODE] Also, your class is missing several very important basic …

Member Avatar for mike_2000_17
0
140
Member Avatar for Weird Nerd

The is a complete [URL="http://msdn.microsoft.com/en-us/library/aa364418(v=vs.85).aspx"]set of functions[/URL] from WinAPI to "browse" the folders for the files. Personally, I think they are crap (annoying and kind-a hard to use). But, that is what the Open/Save file dialogs use in MFC or win32. I would recommend you use [URL="http://www.boost.org/doc/libs/1_47_0/libs/filesystem/v3/doc/index.htm"]Boost.FileSystem[/URL], it is much …

Member Avatar for mike_2000_17
0
120
Member Avatar for brynjar

In C++, we don't tend to use C style arrays, it is more common and easier to use standard classes that can hold arrays. In this case, you can use either std::vector<double> or, if you have a reasonably recent compiler, std::array<double,2>, as so: [CODE] #include <iostream> #include <array> using namespace …

Member Avatar for lcordero
0
230
Member Avatar for Stefano Mtangoo

[URL="http://oss.sgi.com/projects/inventor/"]OpenInventor[/URL] is a pretty useful tool to make OpenGL programming easier by providing lots of built-in functionality.But there are [URL="http://www.opengl.org/resources/libraries/higherlevel/"]many others[/URL].

Member Avatar for Stefano Mtangoo
0
236
Member Avatar for LevyDee

As for the static_cast vs dynamic_cast, the only difference in effect between the two is that the dynamic_cast does a run-time check to see if the cast is possible. In other words, if you pass a pointer to class A, and try to cast to a pointer to B, then …

Member Avatar for LevyDee
0
120
Member Avatar for DJSAN10

To give a more useful answer, that is, knowing what typically could happen when you delete a pointer twice might help you recognize the situation if you see those symptoms. So, although it is undefined behaviour, as arkoenig mentioned, there are a number of things that would typically happen if …

Member Avatar for DJSAN10
0
670
Member Avatar for the_kitoper

Because the date in a "[URL="http://www.cplusplus.com/reference/clibrary/ctime/tm/"]tm[/URL]" structure is counted from year 1900. Which means that 2011 is stored as 111. Generally, if you want to print a string from a time_t structure, use the function "[URL="http://www.cplusplus.com/reference/clibrary/ctime/ctime/"]ctime[/URL]". Or, to convert from "tm" structure, use "[URL="http://www.cplusplus.com/reference/clibrary/ctime/asctime/"]asctime[/URL]" or "[URL="http://www.cplusplus.com/reference/clibrary/ctime/strftime/"]strftime[/URL]" for special formatting.

Member Avatar for pseudorandom21
0
179
Member Avatar for tiredoy

@tkud: What you are describing is what I call "derived class intersection", which is a very classic misunderstanding of what base classes are useful for. I suggest you revisit your understanding of the topic. Learn from the saying "Inherit not to reuse, but to be reused". @tiredoy: The main purpose …

Member Avatar for mike_2000_17
0
233
Member Avatar for tiverton

Taking your code to the 21st century, and doing correct indentation (which helps understanding the code), we get: [CODE] #include <fstream> #include <iomanip> #include <iostream> #include <algorithm> #include <conio.h> using namespace std; int amountRead = 0,max_read = 99; const int maxn = 4200; float array[maxn] = {0.00000}; void getfloat(); void …

Member Avatar for tiverton
0
206
Member Avatar for fashxfreak

No. The best algorithm is to check that all off-diagonal terms are equal (within a tolerance). And, there are (N^2 - N) / 2 checks to be done, which is of order O(n^2).

Member Avatar for m4ster_r0shi
0
122
Member Avatar for awah mohamad

cout is in the std namespace. You need to either qualify it fully, like so: [CODE] #include <iostream> int main() { std::cout << "Hello World!" << std::endl; }; [/CODE] Or, you can issue a "using namespace std;" statement, as so: [CODE] #include <iostream> using namespace std; int main() { cout …

Member Avatar for sashankalladi
0
184
Member Avatar for logan_231_2009

I may be wrong here, but isn't the CPM simply solved by formulating the problem as an Action-On-Arc (AOA) graph. Then, you just solve for the solution using a standard shortest-path algorithm (evidently, you multiply the costs by -1 to get a longest-path algorithm). You can, for instance, use the …

Member Avatar for user786
0
3K
Member Avatar for salah_saleh

>> it looks to me more like a function Or like the construction of an object, which it is. If I have a class named "my_class", I can create an object of that class with "my_class()", which means the object is default-constructed and doesn't have a name (a temporary). So, …

Member Avatar for salah_saleh
0
107
Member Avatar for Blacksheepjnr

Use [URL="http://www.cplusplus.com/reference/stl/vector/"]std::vector< std::string >[/URL].

Member Avatar for Tellalca
0
112
Member Avatar for dilequeno

I think that your intent with the dm_energy_vec class was to just make an alias for the vector<float> type, this can be done with a typedef, as follows: [CODE] typedef vector<float> dm_energy_vec; [/CODE] Then, all your code should work. If you actually want to make the dm_energy_vec class more complicated …

Member Avatar for dilequeno
0
102
Member Avatar for alwaysLearning0

>>You should write a beginner's tutorial on C++0x for Daniweb. That will be a great way to promote this site. I can also contribute on some easier topics!!. That's a great idea! I think most advanced programmers can just look at the wiki or Bjarne's FAQ page, and totally understand …

Member Avatar for mike_2000_17
1
161

The End.