1,358 Posted Topics
Re: [B]>>I have 2 one dimensional vector which are inside structure[/B] I don't think you understand what you actually have. You have 1 vector composed of instances of a struct you've created, called "PopL". This struct in turn contains 1 vector composed of doubles. You do NOT have 2 vectors contained … | |
Re: Your basic structure is correct. The problem is Line 13. An else must follow directly after its associated if or the connection will be broken. Line 13 breaks that connection. You will need to move that into the block controlled by your if statement. Due "Truth in Education" (or similarly … | |
Re: Do you want the overload to be part of your Rational class or a global function? It makes a huge difference in how you declare it, how you implement it, and how you write the statement(s) that attempt to use it. On a side note: [QUOTE][CODE]Rational operator +(Rational);[/CODE][/QUOTE] This is … | |
Re: Take it in as a string. Then, find the colons and break the string up to get what you need. | |
Re: You definitely can't use find_first_of and substr. They are members of the std::string class, and as such must be called using either the "dot" or "arrow" operator on a std::string object or pointer to std::string respectively. This means you won't even be able to get to them from a C-style … | |
Re: The [tex](b^2 - 4ac)[/tex] portion of the equation is called the "discriminant". In order for the quadratic equation to solve properly, the discriminant must be greater than or equal to zero; it can not be negative. You should calculate it and determine if it's within the legal range before you … | |
Re: [QUOTE=XodoX;1455146]When you don't know it, stop spamming people's threads.[/QUOTE] I also know the answers, but there needs to be better demonstration and conversation on your part first. [URL="http://www.daniweb.com/forums/announcement8-2.html"]Another reason similar to arkoenig's.[/URL] Here are some hints: Questions a and b are about the basics of pointers and how they work. … | |
Re: First, move your return statement on Line 40 outside of your for loop. As written, the function returns at the end of the first iteration of the loop instead of at the end of the function. Second, FindLN() returns an int*, but lnt is a double*. You better double-check what … | |
Re: I'm really not familiar with VS-2005, I use 2008. Try right-clicking your project to see if there are "build", "debug", and/or "run" options on the context menu. | |
Re: I don't see a main() function in any of your posted code. Do you have a proper main() in one of your *.cpp files? An example:[CODE] //sample.h #ifndef SAMPLE_H //check for previous inclusion #define SAMPLE_H //establish header guard class Sample { private: int myInt; public: void SetInt(int); }; //end class … | |
Re: I don't do anything with GUIs or CLI, but I noticed you are using the compound addition operator to attach the EventHandlers. Maybe I'm missing something, but shouldn't that be the regular assignment operator, not a compound operator? | |
Re: [QUOTE=MosaicFuneral;1454494]Don't be rude. Most posters are beginning programmers, or have had a long night.[/QUOTE] ??? I'm glad you know what that means. It just looks like spam to me... I'm tempted to report it for not being written in English. | |
Re: Have a look at this:[CODE]if ((retval = conn->get_connected (hostname, service)))[/CODE]You're performing an assignment within the condition of an if statement. That's almost always a no no. Was this your intent? Remember, a non-zero value in a conditional is considered true. Only a NULL/0 value is considered false by a conditional. … | |
Re: @Zjarek: Actually, there is a problem on Line 11 also. Did you notice how the syntax highlighting changes on that line? The OP has escaped the closing double-quote in the string literal. This has messed up the pairings of the remaining double-quotes thus messing up the interpretations of the various … | |
Re: [QUOTE=alexchen;1451120]Line 11. You cannot open a char. Ifstream can only open a file.Don´t use the same names in your code. [CODE]balwin.open("filename.txt");[/CODE][/QUOTE] Actually, that's fine. The ifstream::open() method requires a C-style string as an argument. A C-style string is a char*, which an array of char is so long as there … | |
Re: [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]You may want to read this before you decide to post again.[/URL] [URL="http://www.daniweb.com/forums/announcement8-2.html"]Oh, and this too.[/URL] | |
Re: [QUOTE=Duki;1453961]I charge $25/hr to check for errors.[/QUOTE] Only $25/hr? Bummer, I guess I'm going to have to cut my rates... :P | |
Re: That probably will compile but won't link properly. You are attempting to pass in actual objects instead of pointers to objects which causes the linker to look for a different overloaded version of the function/method. If it does compile & link successfully, you'll probably get memory errors and/or crashes. For … | |
Re: Your doing a lot of stuff on Line 4, the pointers may not be resolving properly. Try adding some more parentheses:[CODE] [B][COLOR="red"]([/COLOR][/B]reader.rdbuf()[B][color="red"])[/color][/B]->pubsetbuf(reinterpret_cast<char*>(&[COLOR="red"]([/COLOR]data[0][color="red"])[/color]),data.size()); // create variable[/CODE] | |
Re: Well, they mean different things. They all accomplish the same basic end result, BUT whether the rewritten version(s) works properly or not depends on how the calling code is written and what type of return that code is expecting. The different argument/parameter formatting will also affect the efficiency of the … | |
Re: I think you're going to want to create a custom class/struct to represent the structure of the data then write a custom comparison function.[CODE] struct Sample { std::string var1, var2, var3, var4, //...etc... }; void readFileLine() { } bool compareBasedOnMember() { //... //return true/false }[/CODE] | |
Re: [URL="http://en.wikipedia.org/wiki/Const-correctness"]It's because of a concept commonly called "const-correctness".[/URL] It's also a matter of creating code that makes sense both logically and mathematically. Operators generate temporary objects while they are processing. If you put the proper debug/output code in your constructor(s)/destructor(s) you can actually see them being created and destroyed. For … | |
Re: Notice anything missing??? [CODE]class Deck { public: Deck(); Card cardAt(int pos); Card *deck[52]; } //<---????[/CODE] | |
Re: You'll have to share some specifics about the first few errors returned and some more code. Without specifics, we really can only make wild guesses. You're speculating about the '<<' operator, but it doesn't appear anyhere in the code that you have posted. This means that either you posted the … | |
Re: Since you only have 1GB of RAM, I suspect you are attempting to do this on a 32-bit system. I'm a little concerned about how much of the original file you'll actually be able to read through. Because of how pointers and file reading work, a 32-bit system may have … | |
![]() | Re: Take a closer look at your class declarations. You have declared user-defined default constructors, but you haven't implemented them in your *.cpp files. You need to provide implementations. ![]() |
Re: A dataType** is a pointer to a pointer to an instance of dataType (2-levels of indirection instead of 1).[CODE] int myInt = 150; int *pMyInt = &myInt; int **ppMyInt = &pMyInt;[/CODE] You'll have to write your converter to return a pointer to the pointer you are trying to convert. | |
Re: Have you learned about classes and inheritance yet? Based on the context/phrasing of the question, I can see where that could be some sort of bastardized term used to refer to polymorphism as well. | |
![]() | Re: The first thing I would check is what configuration you compiled it as. An application compiled with "Debug" configuration will not run on another computer unless it has visual studio installed. You have to compile with the "Release" configuration. The different configurations use different libraries and resources. Most machines don't … ![]() |
Re: [QUOTE][CODE]void node::addMiddle(int x) { node *ptr = new node(); ptr = head; node *nw = new node(); for(int a = 0; a < count()/2; a++) { ptr = ptr->next; } ptr->i = x; }[/CODE][/QUOTE] Okay, the first thing I see here is a massive memory leak. You declare "ptr" and … | |
Re: I noticed that your char arrays (C-Style strings) are not initialized. I would consider fully initializing them with NULLs.[CODE] char myCharArray[15] = {'\0'};[/CODE] I also noticed that the "dataType" array is only 3 char long, you may want to consider making it at least 4 so that you have room … | |
Re: That depends on your definition of "trivial". It also depends on how you intend to use the class and how much control you want over the data that is contained within an instance of the class. Care to provide some sort of example for discussion purposes? | |
Re: You are correct. A reference is not actually an instance of a class. A reference is more like a pointer, but doesn't have all the extra syntax. Thus, the reference can reach the end of its life, or go out of scope, without destroying the original object because the original … | |
Re: classes have 3 access levels [B]private[/B], [B]protected[/B], and [B]public[/B]. The [B]private[/B] level prevents access to members by [B]any code outside the containing class, including derived classes[/B]. The [B]protected[/B] access level is approximately the same as the private level, but it allows derived classes access to members of that access level. … | |
Re: [QUOTE=Moschops;1449797]What's the actual error here? I note that you're using new and feeding it Seat("A1", true) What happens if you abandon using new and just try this, within your actual main function? [CODE] Seat A1 = Seat("A1", true);[/CODE] Also, I don't see how this could possibly compile, as your seat … | |
Re: The purpose of the copy constructor is to create a copy of the object used to create the new object. In order to do that, you must copy the data from the original object to the new object; the information transfer doesn't happen automagically. You're getting a bad output value … | |
Re: Look up the function [URL="http://www.cplusplus.com/reference/iostream/fstream/is_open/"]fstream::is_open()[/URL]. There are also versions for ifstream and ofstream objects. | |
Re: [QUOTE=bensewards;1446430]Hey guys, This is only my second thread on DaniWeb and I am a beginner programmer. My code looks like this: (really easy to understand and shouldn't need any further explanation besides the fact that I need help understanding why when i give an answer related to the 'else' loop, … | |
Re: Arrays are pointers. Send an appropriate pointer. You will also need an integer counter.[CODE] void sampleFunction(const int *, const int); //function prototype int main() { const int SIZE = 10; //a constant to control the array size int myArray[SIZE] = {0}; //the array sampleFunction(myArray, SIZE); //call your function for (int … | |
Re: The code you've posted is both technically and syntactically valid. Whether it works properly or not depends on how you've defined inFileDrs and outfileDrs and how you use tableCount and firstFilePos elsewhere in your code. My only concern is that you didn't initialize tableCount and firstFilePos, you only declared them. … | |
Re: [QUOTE=Narue;1442635]What's endl supposed to do when applied to cin?[/QUOTE] I think it may have been a typo. The post has been edited since you posted. @OP: The main thing I see is that you are trying to input a string of characters to a variable declared as a single char. … | |
Re: I see a few things here. 1. main() must return zero (0) if the program ends normally/successfully. The operating system considers any other return value to be indicative of an application error. 2.You are using a [B]char[/B] as an input variable. A char is only capable of holding a single … | |
Re: Please define "it works fine" and "it isn't working". Without a program description, we have no way of knowing what is correct and what isn't. | |
Re: A bit is nothing more than a single "switch" that can be in either an ON or OFF state. An ON bit is represented as a one (1) and an OFF bit is represented by a zero (0). The Bitwise NOT inverts all bits in the value it's applied to. … | |
Re: I think you're trying to cram too many commands into a single statement. The error will be easier to see if you simplify your statement(s). The function strcpy() is a function from the C library, it is not a C++ function. It uses C-style strings, not newer C++ - Style … | |
Re: >>i am tired As are we, of you trying to cheat your way through your class. DO YOUR OWN HOMEWORK. | |
Re: First, when posting code, please use code tags. We can't even begin to provide effective help if we can't read your post. #include <iostream> int main() { std::cout << "This looks nice, and is easily readable." << std::endl; return 0; }[/CODE] #include <iostream> int main() { std::cout << "This looks … | |
Re: Another option may be to start the session on the page with the form, instead of the second page. You could then store the ticket in the session. | |
Re: A general description of the goal(s) and comments within the code are probably the single biggest help. For this reason, you should ALWAYS make sure that your own code is well commented. Believe it or not, code can be considered written communication (like a book or technical manual) as well. … |
The End.