1,358 Posted Topics
Re: This assignment is all about polymorphism, which is an extension of inheritance. To create polymorphism you must declare a pointer to a base class object, then store a pointer to a derived class object in it. [CODE]LinkedList * new_add = new Stack;[/CODE] Once you have done that, you will be … | |
Re: Put it in a header: structHeader.h [CODE] #ifndef STRUCT_HEADER //begin header guard #define STRUCT_HEADER struct someStruc { /* struct elements */ }; #endif //STRUCT_HEADER //end header guard[/CODE] Then #include the header in your other files classA.h [CODE] #include structHeader.h class A { /* class members */ };[/CODE] classB.h [CODE] #include … | |
I have seen in a couple of places that strstream objects are deprecated, but there are also stringstream objects. My compiler has 2 headers <strstream> and <sstream> and I don't know which is which. In light of this, which header should I use to produce more modern code? I suspect … | |
Re: Vectors only resize if you call the [URL="http://www.cplusplus.com/reference/stl/vector/resize/"]vector::resize()[/URL] or [URL="http://www.cplusplus.com/reference/stl/vector/push_back/"]vector::push_back()[/URL] methods. If you are accessing/modifying the vector using the subscripting operator (i.e. vectorName[index]) they act just like a regular array and will cause segmentation faults. [URL="http://www.cplusplus.com/reference/stl/vector/"]More info on vectors in general.[/URL] edit: Wow, 1,000th post. Doesn't seem possible... | |
Re: Then that's exactly what you need. As you go through the rows, if a row with the appropriate ID exists, echo a 'checked="checked"' as part of the checkbox's <input /> HTML tag. That will make it render in a "checked" state. | |
Re: Good luck with your homework assignment. No one here will do it for you. Try it first, then we'll consider helping you fix your errors. | |
Re: [QUOTE=Agilemind;1302921]And what is the real moral of this story: Don't use an insecure wireless connection for any personal information.[/QUOTE] Can I get an AMEN!!!? | |
Re: I can't give specifics because I don't know Maya or Mel, but there should be some sort of Software Development Kit (SDK) or Application Programming Interface (API) that you can interact with. Try googling "Maya API" and "Mel API" and see what you can come up with. | |
Re: Nice job of spouting off your assignment, but you really haven't given us anything about your expectations for your program or any information about what is/isn't working the way you expected. Did you even bother to read it yourself? Your code is full of throws, but there aren't any try … | |
Re: A newline is a whitespace. Your ifstream object's read location should see it and automatically move to the next line and read the next value. Just be sure you don't add the line numbers like you appear to be showing, they will be read as additional input. Unless you somehow … | |
Re: Are you somehow not dereferencing a pointer properly? This would result in displaying the physical memory address instead of the data stored at the address. | |
Re: So figure out how to define set::positionOf(). Once you have made an attempt, let us know how you did. | |
Re: The header <string.h> is the pre-standard version of the standard <cstring> header. This header is used for manipulating C-style strings (null-terminated arrays of char). To access the member functions of the built-in C++ string type, you need to use the header <string> instead. What are the contents of the file … | |
Re: [QUOTE]Oops, I did that very wrong, sorry!! I'll repost if you want me to.[/QUOTE] NVM, common rookie mistake. I'm sure a mod will fix it soon enough, just be mindful in the future. Snippets are intended to be useful little chunks of code that you would like to share with … | |
Re: [QUOTE=wizrad;1300914]So I have this really simple situation and I have no idea what is causing this error. This is the relevant bit: header: [code=c] class foo{ void bar(int n); } [/code] cpp: [code=c] #include "foo.h" foo::bar(int n){ }; [/code] And then, from the main function in a separate .cpp file, … | |
Re: One nice thing about C++ is the way it interprets true and false. There are, of course, the keywords [COLOR="Green"]true[/COLOR] and [COLOR="Red"]false[/COLOR], but you can also use [COLOR="Red"]zero[/COLOR] vs. [COLOR="Green"]non-zero[/COLOR]. Zero is false, and non-zero is true. All you need is: [CODE] if (sftp->Connect(hostname, port)) { //perform your transfer if … | |
Re: That means that you are somehow specifying the file name as "dateStr.txt" rather than using the contents of the variable dateStr. [URL="http://www.cplusplus.com/reference/clibrary/ctime/strftime/"]Perhaps this function will help.[/URL] Maybe try something like this?: [code] #include <ctime> #include <iostream> #include <fstream> using namespace std; int main() { const int MAX_CHARS = 25; time_t … | |
Re: It looks like you want a set of Node pointers. However, the way you wrote your declaration you are trying to use the '*' improperly. You are trying to dereference a Node object instead of declare a pointer. The '*' must be placed after the data type to declare a … | |
Re: you do realize this thread is almost 6-years old... the OP has probably completely forgotten about it by now. | |
Re: Here's some help: 1. [URL="http://www.google.com/"]Do some research[/URL] [LIST=A] [*]Try "accumulators" [*][url="http://www.cplusplus.com/doc/tutorial/control/"]Do additional research on proper looping[/url] [/LIST] 2. Find a piece of paper 3. Find a pen 4. Begin writing an algorithm 5. Begin translating algorithm to pseudocode/code | |
Re: Wow, a very nice first post. I just wish I could help. Unfortunately, I don't see anything ATM. All of your braces seem to be paired up properly, I don't see any missing semi-colons, and all of your parentheses seem to be in order. Perhaps you should add some parentheses … | |
Re: I'm having trouble understanding the phrasing of your post, but one of your issues seems to be that you're having trouble outputting to a file Concerning your file output situation, please read [URL="http://www.daniweb.com/forums/thread299887.html"]this thread[/URL]. It looks like that poster was having the same problem you are. [edit] BTW: Despite the … | |
Re: I don't know if this will address your problem or not: [CODE]class point { int x; int y; int z; public: point(int=0,int=0,int=0); void prompt_values(); void disp_point(); double distance(point); int compare(point); } //<--- This is a problem //a semi-colon is required[/CODE] If you forget the semi-colon after the definition of a … | |
Re: It's called side effects, it is generally not a good idea to program statements like this because of the unpredictability of them. This unpredictability comes partially from operator precedence, but not entirely. The increment and decrement operators have higher precedence than multiplication, division, and modulus, and postfix versions have higher … | |
Re: [URL="http://www.cplusplus.com/reference/clibrary/ctime/localtime/"]The term localtime is an existing symbol too.[/URL] I wasn't 100% sure at first, the syntax highlighting in your code block actually tipped me off... Probably better off using something a little more obfuscated, ?or even in a different language?. Perhaps use customTimeClass, leTemps (it's French, "the time") or something … | |
Re: I'll give you the benefit of the doubt and assume that's true, but I'm giving you a friendly warning. You really should have said that and posted your code sooner. You would have gotten better help because the post wouldn't have looked so "givemethecodez", which is frowned upon. That's why … | |
Re: Streams use bit flags to hold certain information. To manipulate these flags, you need to use the bitwise operators and special constants. [URL="http://www.cplusplus.com/reference/iostream/ofstream/open/"]You need to use the BITWISE OR to combine multiple file access modes when opening a file stream.[/URL] One mode constant does not imply any other, they are … | |
Re: [QUOTE=mike_2000_17;1287774]@Kanoisa (saransh, please ignore): >> //this shouldent work it should be delete [] ptr. For primitive types like char, it works fine. When dealing with objects with non-trivial destructors, if delete[] is not called it will not call the individual destructor of each element, but the overall memory is still … | |
Re: [QUOTE=vinochick;1056620]Here is what I have so far. I understand the middle portion of it. I'm just having a hard time understanding which variables to stick in the voids. [CODE]#include <iostream> #include <iomanip> using namespace std; //function prototypes void getFahrenheit(); void calcCelsius(); void displayCelsius(); int main() { //declare variables int fahrenheit … | |
Re: [CODE]std::string myString = "A string consisting of letters, ABC, and digits, 123"[/CODE] Or did you mean something more like this: [CODE] std::string myString = "ABC"; myString + " 123"; std::cout << myString << std::endl;[/CODE] I think you'll have to clarify... | |
Re: There aren't really any "naming rules" per se. It's more a matter of common sense and personal preference. Many people will add a 'c' at the beginning of a class name to indicate that it's a class name. But, using bank accounts as a simple example, something like this would … | |
Re: This probably showed up near the top on Google, but there is a lot of info in the reference section of [URL="http://www.cplusplus.com/reference/stl/"]cplusplus.com[/URL] | |
Re: That would work, but I suspect the OP is not familiar with those yet. If you're not exactly familiar with how a binary number system works, addressing the 2^0 condition would be rather confusing. Of course, this is completely dependent on what the OP has already learned, and the lesson … | |
Re: [QUOTE=sadds;1201650]did the computer science teacher ask you it on a test?[/QUOTE] You bumped a 6-year-old thread for that???? | |
Re: Take another look at your [B]default[/B] constructor: [CODE]Student::Student(){ gptr = new int[3]; }[/CODE] In this constructor, what is the size of the array?... It's the default size of 3... Perhaps writing it this way will make it easier to see what it is doing: [CODE] Student::Student(){ const int DEFAULT_SIZE = … | |
Re: You need to change the name of watercar::go() to watercar::move(), that will address part of your issue since it will take care of the error mentioning the missing overload and inability to link. Once that is corrected, you will still have intent errors that need addressing. To address them, you'll … | |
Re: Since you keep saying "array", I wonder if you don't want a multi-dimensional char array? [CODE] char myCharArray [][80] = {"This is question 1", "This is question 2", "This is question 3", "This is question 4"}; [/CODE] | |
Re: They control how accessible the members of a class are. It's a pretty easy google search. [URL="http://www.cplusplus.com/doc/tutorial/classes/"]Read this for more information.[/URL] edit: looks like firstPerson beat me to it... | |
Re: There is truth to your instructor's statement. Nearly all programming languages are composed of keywords that implement datatypes, hardware control, logic, etc. The difference is the words and symbols that are used to implement the logic and the rules that the statements must follow. Logic is logic is logic is … | |
Re: Generally, I wouldn't be this blatant, but I think it warranted this time. Look at Line 72, the first line of your main(). [CODE] Phone thePhone(Andrew, Daniel, 4906996);[/CODE] You are trying to send Andrew and Daniel to the function. The problem is that C++ sees them as undeclared variable names. … | |
Re: I didn't know him, but I had the privilege of interacting with him several times on the C/C++ forums. It was always immediately obvious that he knew what he was talking about. I really appreciated his style. He really knew how to set you straight without making you feel more … | |
Re: Inside Foo::doIt() you declare a new "this" pointer that is non-const, call it "newThis" then const_cast "this" to get the address of the current object. You then dereference "newThis" to access num and change the value. Can I show the solution here? I'm sure it's possible to do it without … | |
Re: Split your program into a calculation loop and a display loop. Your calculation loop would be what you already have, minus the output statement (Line 13). Your display loop would be the same, but start at 0 and only have the output statement. Also, you need to be careful about … | |
Re: The variable gradez shouldn't be an array. All you have to do is declare it and initialize it to NULL. [CODE]char aChar = '\0';[/CODE] Then, after you get it from the user, verify that it's either 'A' 'B' or 'C' and simply increment it: [CODE]cin >> aChar; aChar += 1;[/CODE] … | |
Re: *Snore*..... Seen this one before. It's very easy if you actually try. It probably took you longer to type the post than it would have taken you to do the assignment... | |
Re: Double-Quotes ( " " ) are used to enter "string literals". Single-quotes are used to enter a single character i.e. 'C' [CODE] std::string myString = "This is a string literal, it uses double-quotes."; char charString[80] = "This is also a string literal."; char myChar = 'C' //this is a char … | |
Re: What have you tried so far? What kind of results are you currently getting? We can't even begin to help until we know what you have and what you've tried. | |
Re: It seems to be flagging line 13. On that line, should the "__signed" be a "signed"? I don't think I've ever seen it with the double underscore before... | |
Re: Are you trying to get the whole array or just a single element of the array from getValue(). Either way, you'll have to at least change the declaration and potentially the implementation. If you want the array, you have to return the pointer: [CODE] int[COLOR="Red"][B]*[/B][/COLOR] gimmeTheArray() { return arrayName; }[/CODE] … | |
Re: They both work because a char is really just a small int (1-byte instead of [I]typically[/I] 4-bytes). The difference is the way the system interprets them by default. |
The End.