1,358 Posted Topics
Re: I'm afraid we can't really give you project ideas because we don't know you or your abilities. All you can really do is keep your eyes open and pay attention to what you're working on. Then, if you notice something that you could make simpler to do by writing a … | |
Re: What IDE are you using? I use VS 2008 Pro and I get the same thing when I try to inline in the *.cpp file. I don't think VS can do it. There must be something about how it interprets the inline keyword that messes up the linker. EDIT: Did … | |
Re: Please post some code. We have no way of knowing what is happening if we can't look at the relevant portions of your code. | |
Re: We really can't give you specifics. We don't know you, your abilities, or your interests. We could literally make hundreds of suggestions but all it is is an exercise in futility, and they are of no value, if they don't suit your interests and/or abilities. You say you "got the … | |
Re: Do you see the numbers in parentheses in the errors? Those are Line numbers. The first three errors are flagging Lines 31 and 34. Here are lines 29-34 of your code, for reference:[CODE] /*29*/ bool again = true; /*30*/ do; /*31*/ { /*32*/ showMenu() // Visa menyalternativ /*33*/ /*34*/ cout … | |
Re: I've read the book as well. It tends to cover a lot in a hurry, sometimes without adequately explaining the underlying theory. A reference is like a pointer, it is not as powerful, but can be both very useful and very dangerous at the same time, which this code demonstrates. … | |
Re: What are your errors? It's hard to get very specific without that information. At first glance, though, I can see a couple things that should be addressed. [list=1] [*]You have not terminated your class declaration with a semi-colon. When you don't, it confuses the compiler. [*]You can't initialize a member … | |
Re: I doubt it's a problem with [B]your[/B] code since it runs properly in Debug mode. Is there a section of code in your program that deals with either localization, dates or times? It may be a good idea to post that section for review and comment. It's also possible, depending … | |
Re: When troubleshooting, you should always address the first reported error first. The first error says[QUOTE]D:\12-22-10\jhyjhjkh.cpp(22) : error C2447: missing function header (old-style formal list?)[/QUOTE]This error refers to the header line of this function:[CODE] int Large(int Array[],int N, int& Big);{ int Big = 0 for(N=0,N<10,N++;){ if (Array[N] > Big) Big= Array[N]} … | |
Re: You are correct. When you create an independent block, such as that in Lines 4 - 7, the variables are local to that block. Any variable that is created within that block goes out of scope and is destroyed when the block ends, unless it was dynamically allocated. Alarm bells … | |
Re: First, you need to get the size of your array right. A 20x20 array of char doesn't hold 24 strings. It holds 20 strings that are up to 19-char long. | |
Re: [URL="http://www.cplusplus.com/reference/iostream/manipulators/fixed/"]Use the "fixed" stream manipulator.[/URL] [CODE]#include <iostream> using namespace std; int main() { const double PI = 3.14159265; cout << fixed << "The value of PI is: " << PI << endl; return 0; }[/CODE] | |
Re: I suggest you think about coding as being a lot like putting together a puzzle. First you assemble the edges/frame, then you fill in the middle until you get the final image. During the process, you need to make sure that every piece you add works with the rest of … | |
Re: There's not much here to work with. It may be beneficial to post more of your code. A few questions for you to think about/answer (in no particular order): [LIST=1] [*]How is "changeAmount()" defined? [*]Is "K" a constant or a variable, and is it visible to both classes? [*]Are you … | |
Re: Maybe I'm confused, but isn't this an example of the assignment operator, not the copy constructor? Wouldn't the copy constructor be more like this:[CODE]Class A { ...... }; main () { A * obj_1=new A(); // Next the obj_1 variables are initialized //Make a copy of obj_1 A * obj_2=new … | |
Re: [B]>>I'm thinking about making the primes vector global, so I won't need to re-create it every time, but I don't think using global variables is very OOP-like. Any suggestions?[/B] I don't think I would worry too much about how "OOP-like" it is at this point; you're not really doing any … | |
Re: The problem isn't cin. It's your variable(s). Your variable "name" is a single char, it's neither a C++-style std::string nor a C-Style char array. It must be either of those 2 types to hold a person's complete name. | |
Re: It is possible to invoke an object's Destructor, if you define your own, but it's not recommended because it's likely to cause errors when the object is actually destroyed. You're better off destroying the actual object. The Destructor will be automatically invoked for you as part of that process. | |
Re: I'm assuming based on your wording that your program is currently all procedural. Since it's currently working, I think separating it into header and implementation files would be a good organizational start. That would allow you to re-use your existing code, you would just be putting it in different files. … | |
Re: Don't have any e-books, [URL="http://www.cplusplus.com/doc/tutorial/structures/"]but this should help[/URL]. It's a C++ tutorial on how to build them. The next 3-4 pages cover a variety of custom data types that you can use. | |
Re: What you are experiencing is the result of "[URL="http://en.wikipedia.org/wiki/Endianess"]endianess[/URL]" which is a system-specific behavior. However, most modern systems have a "little-endian" configuration. In a little-endian configuration, the right-most bit of a word represents the smallest value (i.e. 1). Thus, if you have a 32-bit int whose value is one (1) … | |
Re: He did. What happens when (range == i)? How does your code recognize and address that situation? It doesn't, but it needs to. | |
Re: Do you know how to copy from one array to another? You should, [URL="http://www.daniweb.com/forums/thread332892.html"]after your other thread[/URL]. All you need to do is take that solution and modify/expand it to fit this situation. | |
Re: The algorithm for displaying an array doesn't change from one scope to another. You already do it in your main() with your (what I will call) "preview" loops. All you have to do is replicate that structure in the appropriate location for where you want the array displayed. To make … | |
Re: Well, you didn't specify what your problem is, but I suspect you are getting segmentation faults (crashes) at run-time. The problem is that you are only using "s" as the index of your arrays. If you have 2 arrays containing 5-elements each (elements 0-4). You are going to have memory … | |
Re: What about the vector class' built-in copy constructor? I don't know exactly how it works, but the STL is usually pretty quick...[CODE] vector<type> copyVector(originalVector);[/CODE] Or the built-in assignment operator?[CODE] vector<int> vecOne(10,0); vector<int> vecTwo(20,0); vecOne = vecTwo;[/CODE] Both of these, of course, would require the the dataType stored in the vector … | |
Re: It's really not difficult. Your 3 files are className.h, className.cpp, and main.cpp. You would organize them as follows: [CODE]//Sample.h, the header file, contains class declaration #ifndef SAMPLE_H #define SAMPLE_H class Sample { private: int m_prvInt; public: Sample(); //default constructor void setInt(int); //"setter" }; #endif //SAMPLE_H[/CODE] [CODE]//Sample.cpp, implementation file, contains definitions … | |
Re: For one thing, you can't expect immediate responses to a forum post. Sometimes it happens, but that's not the norm, it usually takes a while. You bumped in less than an hour. [URL="http://www.daniweb.com/forums/announcement8-2.html"]Also, we can't just give you the answers, it's against forum policy.[/URL] If you would like help, we … | |
Re: Is this a "specialization" of an existing template for an int dataType? What compiler and OS are you using? Generally, when you are doing template programming, you want to keep your code as generic as possible. [CODE]template <typename T> T doubleValue (T inValue) { return (inValue * 2.0); }[/CODE] This … | |
Re: Your for loops perform 5 iterations, they should only perform 4. Your loop should end at (arraySize - 1), not array size. This is incorrect:[CODE] const int arraySize = 5; int myArray[arraySize] = {0}; for (int i = 0; i <= arraySize; ++i) { myArray[i] = i * 2; } … | |
Re: [B]>>Simmilar problem again using a vector of length 4[/B] Similar to what? What are you trying to do? If you're trying to pass a vector to a function, it appears that you have not defined your arguments/parameters correctly. To pass a vector to a function, you should define the parameter … | |
Re: What do you mean by "press the 'tab' button twice"? If you want to use a tab to push console output to the right a few lines, use the '\t' escape character.[CODE] #include <iostream> using namespace std; int main() { cout << "\t\tThis output is tabbed over..." << endl; cout … | |
Re: An int can store negative numbers that usually range from about -2.1 billion to about 2.1 billion. An unsigned int can only store positive numbers that usually range from 0 to about 4.2 billion. In a 32-bit system, an int is typically 32-bits long with the first bit being the … | |
Re: Well, the code is reasonably well formatted, but it's sort-of all crammed together in a single file so I'm having a little trouble following it. I can't address your problem specifically so perhaps an example will help:[CODE] #include <iostream> #include <cstdlib> struct Sample { int *pIntArray; int ArraySize; int UsedElements; … | |
Re: It's because you are declaring the class [B]after[/B] you are trying to use it. As a result, the compiler doesn't know anything about the Node class yet. Rearrange your class' declaration so that Node is declared [B]before[/B] you use it. It's just like anything else, you can't use it until … | |
Re: This reeks of a homework assignment, so I'm not going to provide any code at this time. FYI, this is the C++ forum, there is a separate C forum. Also, please use code tags when posting code in the future. They make the code in your post easier to read. … | |
Re: I can't find it at the moment, but there's a WinAPI tutorial out there that tells you how to build a window. In that tutorial, it has you do something with the window handle(s) that makes it possible to only open one instance of the program. If you try to … | |
Re: @OP [URL="http://www.cplusplus.com/reference/iostream/ios/clear/"]The function ios::clear() does not empty a stream[/URL]. If the stream is in an error state it resets the stream's error flags to return it to a usable state. You still need to empty the stream by another method such as istream::igmore(). This method appears to work. But unless … | |
Re: [noparse]The glaring problem that I see is a lack of any connection at all between Checking/Savings and Account outside of the inheritance statement. You don't interact with any part of Account in either Checking or Savings. In an Object-Oriented system, generally it's okay for Derived objects (Checking/Savings) to be aware … | |
Re: I can't claim to be an OOP expert, I've only been studying it for a few months, but in my opinion, you're better off representing a physical object as a class. Each class you define should corerespond to the construction of one of your tables. You would then use each … | |
Re: Can't. Can't read your post. Please re-post with a better description of problem and use code tags then maybe we can help. | |
Re: Yes, but you need to make sure to standardize your input format and institute some good error checking otherwise your user could really wreak some havoc with the application. How are you currently recognizing the "assign strength" command? If you're just using simple string comparison, you'll have to make some … | |
Re: [QUOTE][CODE]int main() { HTTPClient* object=new HTTPClient(); object->SetUrl("http://developer.uidai.gov.in/auth/demoapp/9/9"); o->GetUrl(); o->AddEncodedPostField("input","test1.txt" ); o->Perform(); return 0; }[/CODE][/QUOTE] Where did "o" come from in Lines 5-7? Shouldn't it be "object"? | |
Re: >>Can anyone please help? Not unless you elaborate on the nature of the errors you are getting. Unless you share more information, all we can really do is take wild guesses. I don't think your getNode() is correct. I think you're missing a template argument in the line where you … | |
Re: Is there a question in there somewhere? What are you having trouble with? I'm afraid I just can't figure out how to provide a valuable response to your query. | |
Re: What data type are sum and sumCheck? | |
Re: I've used both. I had to use Eclipse for a class that I took, but I use VS otherwise. The compiler Eclipse uses seems a little more "strict" than the MS compiler, but I don't really like the layout of Eclipse. IMO VS's layout is more intuitive and useful. I … | |
Re: When using malloc(), you need to cast the return to the appropriate type of pointer. From your linked reference:[QUOTE][CODE]buffer = (char*) malloc (i+1);[/CODE][/QUOTE] Notice the "(char*)"? That's a type cast. You need to add them to this code. Whoever the original author of this was must have been relying on … | |
Re: I think you should clarify what you are trying to do. Either your example output doesn't match your example input making it not make sense or your description of the required actions is too cryptic. Example input Line 1: 20 20 1 5 6 Example output Line 1: 20 20 … | |
Re: When a function returns a value, the return is stored temporarily so that the code that called the function can access it. This temporary value doesn't die until the calling code has used it. What you are experiencing with foo() is normal, your experience with bar() is not. Your definition … |
The End.