1,358 Posted Topics
Re: Have you tried changing [icode]#include <FileNames.h>[/icode] to something more like [icode]#include "FileNames.h"[/icode]? The behavior of #include <> is different from the behavior of #include "". | |
Re: Dev-C++ is very outdated. When I started with C++, a little over a year ago, that was my first IDE. I'll be honest, i hated it. None of the features worked properly or in a timely fashion, the code complete would cause a crash 75% of the time. I got … | |
Re: Actually, you can still resolve std::cout and std::endl globally so that you don't have to explicitly resolve them every time you use them. To do so, you would use individual "using" statements instead of a generalized using statement like [iCODE]using namespace std;[/iCODE]. [CODE] #include <cstdlib> #include <iostream> #include <string> //using … | |
Re: I'm answering because you mentioned that you have to learn C. You should be cautious about how you learn to do things because C++ is a "superset" of C. This means that it incorporates C into it and expands upon it. I might suggest "C++: The Complete Reference" by Herbert … | |
Re: Have you tried using combinations of [URL="http://www.cplusplus.com/reference/clibrary/cstring/strtok/"]strtok()[/URL], [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/"]atoi()[/URL], and [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atof/"]atof()[/URL]? strtok() tokenizes character arrays (c-style strings) and atoi() and atof() pull numbers out of strings. | |
Re: A "token" is simply a unit of information that has meaning. For example, in C++ if you want to output to the console, you use the keyword [B]cout[/B]. The keyword [B]cout[/B] is a "token" that the compiler detects to tell it that you want to use the standard output stream/console. … | |
Re: The variable called "val" is not a pointer, it is another (completely separate) integer. It will not automagically update. You must perform another assignment. This code: [CODE]total = 3200;// assign 3200 to total ptr = &total; // get address o total val = *ptr; // get value at that address[/CODE] … | |
Re: Other options for use of istream::get() are: [CODE] char inputChar = '\0'; cin.get(inputChar); [/CODE] or [CODE] std::string myString = ""; int charCount = 24; cin.get(myString, charCount); [/CODE] [URL="http://www.cplusplus.com/reference/iostream/istream/get/"]See this for more prototypes and examples.[/URL] | |
Re: I would start by breaking up your code block like this, for ease of discussion: file1.h: [CODE] //header contents (class definitions) [/CODE] file1.cpp: [CODE] //implementations [/CODE] file2.cpp: [CODE] //your includes: #include "file1.h" int main() { } [/CODE] Doing this makes it easier to understand your project's file set up, which … | |
Re: [QUOTE=Frederick2;1273498][CODE=C++] #include <stdio.h> int main() { int iBAF=10; int iPlots=14; double dblFactor; dblFactor=iBAF/iPlots; //to get a floating point you need a cast! printf("dblFactor = %10.6f\n",dblFactor); return 0; } /* dblFactor = 0.000000 */ [/CODE] I thought C/C++ would offer a few benifits beyond pure assembler. Apparently I was wrong.[/QUOTE] A … | |
I know they no longer appear, but people still link the C++ ones all the time: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] [url]http://www.daniweb.com/forums/announcement8-3.html[/url] I'm sure they still link the other forum-specific ones frequently as well, I just don't visit those forums frequently enough to know. Are those gone too? They were working yesterday, but now … | |
Re: The way your statements are written (with concatenation), if you have single quotes in your strings, the interpreter might be interpreting them as starting new literal strings. [CODE] //these are roughly equivalent $variable = "some string"; $variable = 'some string'; //the big differences are the way escape codes are expanded … | |
Re: [QUOTE=hag++;1273630]Welcome to the forums. I recommend reading the forums rules because you will see that people will not help you with these kinds of questions. You need to first learn the basics of what to do (Read books, classes, etc...), post your code, then if you have problems people here … | |
Re: [URL="http://www.lmgtfy.com/?q=gcc+symbol+table"]This may help.[/URL] | |
Re: Can't... You haven't provided us with a sufficient description of the problem. At this point, all we can do is guess... Does the program compile? If not, what are the compile errors? If yes, what are you expecting the program to do and what is it doing incorrectly? Also, [URL="http://www.daniweb.com/forums/announcement8-3.html"]please … | |
Re: Both files have a variable called "loop" defined within them in the global scope. Those identical declarations are butting heads. I don't see your class definitions for HangmanMenu and MainMenu. Based on the way you are using the "loop" variables I think you would be better off moving them from … | |
Re: Here's a hint: You need to use parallel arrays here. The first is the menu items themselves, the second is a "counter" or "distribution" array. The counter array would have 1 integer element (initialized to 0) for each menu item. Then, as the customer orders items, you increment the appropriate … | |
Re: Your comments explain it all. Your array is only defined to be 9 elements long (see Lines 7 and 8), but you are processing it as if it were 10 elements long. example: Lines 18-22. Your while loop is overshooting the limits of your array. It runs from 0-9 (10 … | |
Re: You are attempting to call the function before it comes into scope. To fix this, you need to add prototypes for your functions to the top of your file. [CODE] //****** //***THIS EXAMPLE CONTAINS AN ERROR AND WILL NOT COMPILE/LINK //****** // the function someFunction has not come into scope … | |
Re: [QUOTE=sjohnson;1270121]I didn't mean to offend u. I've fallen behind in my class and in fear of failin. Nice slap back to reality. Hope I can get tips in the future.[/QUOTE] Not a big deal, you certainly may. Just be sure you follow the [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]forum rules[/URL] and the posting guidelines when … | |
Re: [URL="http://www.daniweb.com/forums/announcement8-2.html"]And what have you done so far?[/URL] If you actually put some effort into it, you might be surprised that you can be done with it in less than 15 minutes. [URL="http://www.cplusplus.com/doc/tutorial/functions/"]Some info on functions.[/URL] | |
Re: To generate a number within a specified range (i.e. -95 to 95, inclusive), you need to take a random number modulo the range. If the highest number in the range must be included, you take the modulo (range+1). Once you have taken the modulus of the random number, you add … | |
Re: You aren't telling boat to inherit from transport. [URL="http://www.cplusplus.com/doc/tutorial/inheritance/"]Read this.[/URL] Also, there must only be one (1) main() in your entire program. It can not be part of any class, it must be globally-scoped. This won't work: [CODE] class someClass { int main() { return 0; } }; [/code] Neither … | |
Re: What is this "dataStructure" type that you are using? It appears to be a templated class... Is it something that you defined? If so, how is it defined? Is your class definition in your main file or in a separate header file? | |
Re: I'm not familiar with CodeLite, but I'd say take another look at your project-creation options. I suspect that shared libraries (*.dll) and static libraries (*.a) are different project types. I know they are in Code::Blocks and in MS-VC++. Also check the MinGW documentation, you can probably just change a couple … | |
Re: Yes, to declare an array it would be [CODE] const int elementCount = 5 dataType varName[elementCount][/CODE] I wrote it this way because the old standard required that elementCount be a constant. Some compilers still enforce this. Newer compilers are starting to allow variables as the elementCount in lieu of constants. … | |
Re: The way you describe your situation is a little confusing. You'll have to show us what you have so that we can understand your description. It sounds like you want to define the function once and have it valid for every child class without re-defining it. To do that, you … | |
Re: :confused: Why do you have 3 loops? You only need 1. The way you set those loops up, I don't even want to know what you'll get. A big mess, that much is certain. [CODE] ifstream inFile("input.fil", ios::in); if (!inFile) return EXIT_FAILURE; double decimalInput = 0.0; int intInput = 0; … | |
Re: If you put in a [iCODE]cout << vtoks[1];[/iCODE] after the line in question, what do you get? Do you get "daimler" or "volkswagen"? Also if you [icode]cout << vtoks.size()[/icode] what do you get, 4 or 5? | |
Re: Private members (whether they be member variables/properties or member functions/methods) are only accessible by other members of the class that contains the private members. For example, class1's private members are only accessible by other members of class1, class2's members and main() are not allowed [B]direct[/B] access. To access the members, … | |
Re: Recently, I wrote a dice game that was set up with several loops. To answer your question though. There is a loop in main() that I called the "application loop", much like jonsca suggested. This application loop was set up like this: [CODE] [B]//this is mostly pseudo code[/B] int main() … | |
Re: [URL="http://www.sorting-algorithms.com"]Here's a site that will help you understand sorting sorting algorithms.[/URL] | |
Re: I don't see any virtual functions. That's probably your issue. [URL="http://www.cplusplus.com/doc/tutorial/polymorphism/"]I suggest you read up on polymorphism, specifically "Virtual Members".[/URL] Oh, and read up on [URL="http://www.daniweb.com/forums/announcement8-3.html"][B][noparse][code] ... code tags ... [/code][/noparse][/B][/URL] | |
Re: Operators defined as members are treated like a member function of the left-hand operand with the right-hand operand becoming the parameter to the function. What both nathan and first are saying is that the A object being passed to the operator is the parameter, not the calling object. Declaring a … | |
Re: You seem to have the right idea, but you are defining your guess array to be an array of integers that is (0) elements long. It's not technically illegal, but it's very unsafe. There might be a better way to do it, but I would suggest you treat it more … | |
Re: There's not really a "standard" for OOP design... There are really just processes with good/bad components to them and good/bad design ideas. What's a good design process and what's a bad design process is highly dependent upon on your personal Point of View. For a general overview of what is … | |
Re: Saying "...each time I compile I get this error massage,..." is too generic, it's not helpful. Give us specifics and we may be able to help... If what is Line 3 in your "snippet" is actually in your code, I'm not surprised there is an error. That should be a … | |
Re: The name "stdafx.*" is the name that VC++ gives to its "precompiled headers"-related files. Some people have trouble with them, some don't. I don't know why. It seems your O/S rebuild introduced the environmental situation that causes the issue. Have you added anything to "stdafx.h" or "stdafx.cpp"? If not, disable … | |
Re: When your program hits the system("PAUSE") line, does it actually pause or does it blow right through it, without pausing? | |
Re: The issue is not that there are extra/missing braces. The issue is that you are trying to define your *ThreeNumbers functions inside of main(). You can't do that. You need your prototypes before main() and definitions after main() like you had in your first version. You simply need to correct … | |
Re: I think you may have that backward dave. Shouldn't it be [CODE] std::stringstream ss; std::string myString; ss << yourThing; ss >> myString;[/CODE] ??? | |
Re: Line 19 of "character.h" you need to add a semi-colon. Class definitions must always be followed with a semi-colon. The rest of your classes and all your constructors look okay. | |
Re: I don't know WINAPI, so I can't help you with your syntax, but it sounds like you are missing a library file that the linker needs. | |
Re: Do you know how long each line is and also how long the file is overall? If not, dynamic allocation will be required and the algorithm changes dramatically. For simplicity, and if allowed by your instructor, you may want to consider using a vector<string> instead of a 2-d array. | |
Re: Are you getting any compilation or run-time errors? You really haven't given us much to go on. I will say, though, that this is not correct: [CODE]const int SIZE = 10; int anArray[SIZE] = {0}; for (int i = 0; i <= SIZE; i++) { /* ... */ }[/CODE] I … | |
Re: Lines 55 and 96 of this post. Which one is wrong? [edit] Wait. Let me look again. I missed the specialization comment. | |
Re: [QUOTE] [CODE]int main(){ SOME_TYPE* list[5]; list[0]->SetName("one"); list[0]->SetValue(1); list[1]->GetName("two"); list[1]->SetValue(2); DisplayList(list); return; }[/CODE][/QUOTE] This is okay, except that Line 5 should be a call to the SetName() method, not the GetName() method, also see note(s) below concerning DisplayList()... [QUOTE][CODE]void DisplayList(SOME_TYPE* list){ for(int loop = 0; loop < 5; loop++){ if(list[loop] != … | |
Re: [QUOTE=Aranarth;1227106]string is included by iostream, so you can just omit the include and still use strings.[/QUOTE] That is not always true. It is far better to be explicit. There is less chance for an issue. | |
Re: [QUOTE=corby;1228477]dont matter. same thing its like sayin a*b versus a * b....its the same thing except for where the space is. the compiler wont care for a space in that situation[/QUOTE] This is relevant to the OP and the previous post's questions how??? This: [CODE]int* a, b;[/CODE] Is not the … | |
Re: Also, I notice you only have [CODE]#include "distribution"[/CODE] if daviddoria's suggestion doesn't help, try adding a ".h" to the name i.e.: [CODE]#include "distribution[B][COLOR="Red"].h[/COLOR][/B]"[/CODE] |
The End.