1,608 Posted Topics

Member Avatar for OmniX

<< Be careful: it was not an example of passing by reference! It's passing a pointer by value. I'll side with Mahlerfive on this one and see if debate follows or not. Passing an objcet by reference is different than passing a reference to an object. The concept of passing …

Member Avatar for Alex Edwards
0
151
Member Avatar for xyzt

The information embedded within the class method has to be stored in memory somewhere, but whether it's attributable the to size of the class or not I don't know. You can try the test yourself. Declare a class with a plain old data type and a second one with the …

Member Avatar for Narue
0
825
Member Avatar for Sukhbir

When you overload the () operator, it is called the conversion operator. It provides explicit instructions as to how to implicitly convert a class object into a built in plain old data type. At least that's how my reference explains it.

Member Avatar for Narue
0
126
Member Avatar for NoGood123

Not quite. Your outer loop is going down and the inner loop is going down, both loops should go the same way. Your inner loop would be a good outer loop to control which element of the array do you start with on any given sequence of the inner loop …

Member Avatar for ArkM
0
332
Member Avatar for scream2ice

>>is there a conversion from "char" to "int"? If yes, how? Yes, you can either go from char to int or from string to int. One of the easiest way to get the numeric value of a char representing a digit is to substract the ASCII (or Unicode or whatever) …

Member Avatar for invisal
0
331
Member Avatar for verone

Welcome to DaniWeb. Please repost using code tags. Almost nobody ever does it the first time around, but it is nice when you do. A few quick observations. 1) main() should return type int, not void, even if your compiler allows the return type void syntax, if for no other …

Member Avatar for Lerner
0
124
Member Avatar for disturbedfan

Assuming you downloaded an up to date version of Dev-C++ you might try something like this:[code] #include <iostream> using namespace std; int main () { cout<< "Hello World"; cin.get(); return 0; }[/code] If that works, and I think it will, then the problem is that the tutorial is out of …

Member Avatar for gregorynoob
0
145
Member Avatar for driplet

read each token from each line one at a time into a string. If the first char of the string is alphabetical, then it's a char and if not then it's numerical (assuming those are the only two options for stuff in the file). If it's numerical then convert it …

Member Avatar for Lerner
0
88
Member Avatar for jonabie

>>can someone tell me how to make an asterisk frame using for loop statement in C++ Give it your best shot and post a specific question with code/error statements/etc as needed. This is a common task that any number of people could help you with, but most of us won't …

Member Avatar for jonabie
0
268
Member Avatar for vulpecula

Are you given the file that looks like this: intstring intstring intstring or are you creating that file? If that's what you are given then read an entire line into a stringstream and parse it using a technique similar to what Ancient Dragon previously posted. You need a different value …

Member Avatar for Lerner
0
186
Member Avatar for Agni

You might try the following untested logic:[code] declare mySentence() to: 1) have return type void 2) receive a reference to a stringstream 3) have a local string variable called token 4) if you can extract a string from the stringstream into token a) recursively call mySentence again passing it the …

Member Avatar for Agni
0
348
Member Avatar for Cosa

I'm assuming the third file posted is dna.h, the middle file posted is dna.cpp and the first file posted is the driver file. Now withing dna.h you declare a user defined type called ecoli. I suspect you want ecoli to have 1 data member, called dna, and 2 functions to …

Member Avatar for Lerner
0
142
Member Avatar for Aia

[quote]There has never been a time in human history where there was no government wherever more than 2 people live together. You can even consider the basic family as a government of sorts -- mom & dad are the dictators and the children are the governed. [/quote] Admittedly, I never …

Member Avatar for Aia
0
761
Member Avatar for QuantNeeds

That's because there's something, probably a single new line char, left in the input stream buffer because you are mixing getline() and >> in the same program. Place a line like this just before the call to getline(). cin.ignore(1086); That should clear the input stream buffer. It isn't perfect, but …

Member Avatar for QuantNeeds
0
141
Member Avatar for jhonnyboy

You have to know the exact arrangement of the file you are trying to read. For example, if the file consists of a series of data arranged by lines with each line consisting of a name and a numerical value separated by a space then you can call the >> …

Member Avatar for jhonnyboy
0
129
Member Avatar for Kanoisa

Please learn to use code tags when posting to this board. That will maintain the indentation I hope you use in your code. You can read about code tags in the anouncement section at the top of the board or by reading the watermarks in the Message box where you …

Member Avatar for Lerner
0
142
Member Avatar for bramprakash1989

I don't do much GUI programming but I do remember that the first thing you need to know is what API you are using as there is no way to do this in standard C/C++. It's all API/GUI dependent. The good news is that the process is similar in a …

Member Avatar for CoolGamer48
0
96
Member Avatar for bpacheco1227

Be careful with the function declarations and function definitions. The return type, function name and function parameters must match. In post #12 line 13 declares fileHighScore like this: int fileHighScore(int,string); and line 227 starts the definition like this; int fileHighScore(int charaChoice,string uname) Those two lines match. However, in post #14 …

Member Avatar for mitrmkar
0
200
Member Avatar for findlay

It sounds like you are experiencing the joys of floating point math, where close enough is what counts. For example, how many threes behind the decimal point does it take to equal 1/3, etc? Similarly what value is 1 x 10^16? For all practical purposes it is zero, unless you …

Member Avatar for Salem
0
149
Member Avatar for CoolGamer48

[code]land = new LandCondition[IMG_WIDTH]; for(int i = 0; i < IMG_WIDTH; ++i) land[i] = new LandContion[IMG_HEIGHT]; [/code]

Member Avatar for CoolGamer48
0
110
Member Avatar for QuantNeeds

Post your enum declaration. I suspect you want something like this: enum Process(END, PRINT, UPDATE, NEW, DELETE); which would be the equivalent of END == 0; PRINT == 1; UPDATE == 2; NEW == 3; DELETE == 4; I'm not sure why you have an end program option since you …

Member Avatar for Lerner
0
256
Member Avatar for kinger29

You can declare an array of type T using static memory like so: T myArray[constInt]; where constInt resolves to an int that is declared const, meaning its value must be known at compile time and cannot be changed at run time. If you don't know what value you want/need for …

Member Avatar for Lerner
0
169
Member Avatar for greyghost86

Salem was trying to teach you a better way to fish, not just toss you a fish. Sometimes you're going to get a direct answer to answer a given problem, and sometimes you're going to get a better way to solve the problem in the first place. I hope you …

Member Avatar for Salem
0
185
Member Avatar for gangsta gama

Every time you call move() to change one of the values within the array you call displayBoard() immediately afterward. Within displayBoard() you write over any changes made in move() putting the array back to the default values, which is why it looks like it isn't changed within move(). Move lines …

Member Avatar for gangsta gama
0
263
Member Avatar for Nemoticchigga

I always hate it when someone changes a descriptive name like short, which is a small integer, to something like word, which to me should be a string of some sort rather than an alias for short. That being said, if you are truly trying to change a string, like …

Member Avatar for Ancient Dragon
0
101
Member Avatar for KenTheFurry
Member Avatar for shariff089

In some worlds everything might work everywhere. However, in this world frequently there are rules that must be followed. For example, in the non-computing world integers can have infinite size, but in C++, the int type, which has been designed integers within written code, has an upper limit of size. …

Member Avatar for VernonDozier
0
128
Member Avatar for Jennifer84

Looks to me like you need a way to identify the start and end of a statement. Looks to me like a new statement is initiated within the examples provided by any of the following '(', &&, and ||. There may be other triggers to recognition of a new statement …

Member Avatar for Jennifer84
0
336
Member Avatar for Emerald214

Are you sure that's the class heiarchy you want? If it were me I'd declare Circle to have a member variable of type Point, since a Circle is not a Point like every Dog is an Animal and every Car is a Vehicle.

Member Avatar for ArkM
0
178
Member Avatar for asad12

mega[i] = draw_index; draw_index is a single int. mega[i] is an array of 6 int. you can't assign a single int to an array of int since they aren't the same type. Since you don't comment on the intent of display_draw() I can't help you correct the problem, only point …

Member Avatar for ArkM
0
109
Member Avatar for omarelmasry

I'd suggest you break down the problem into smaller steps. The first step I would do is to develop an algorithm to generate the next highest number for n of a given, small value, say 3 or 4. Then I'd try to generalize that process. Given the unknown size of …

Member Avatar for Alex Edwards
0
148
Member Avatar for fmwyso

Go to google.com. Search using the words: using STL set. I liked the sgi site but there are others to peruse as well.

Member Avatar for Narue
0
323
Member Avatar for SunshineLuvr

1) It never pays to write more than one function/method at a time and then try to debug it. The only exception would be the need to write a default constructor and a method to display the variable members of the class if you don't use your debugger. 2) If …

Member Avatar for mitrmkar
1
585
Member Avatar for monkey123

Not a bad start to the function. You might want to expand that for change up to 10 dollars rather than single dollar bills being the highest denomination of change available, but otherwise the concept is good. Now for a question rather than a request.

Member Avatar for CoolGamer48
0
83
Member Avatar for anuizath2007

>The problem actually is i dont get the corect no of spolit ballots...i get it as 4325678> between line 10 where you declare the variable called invalid and line 26 where you increment the variable called invalid by one you never initialize/assign the variable called invalid to any given value, …

Member Avatar for anuizath2007
0
292
Member Avatar for QuantNeeds

Why the cast to type char regarding the variable seating[]? Or in otherwords, seating is an array of what type?

Member Avatar for Duoas
0
3K
Member Avatar for cam875

A switch statement is a common way to handle code with multiple options to choose from. However, it can be done with ifs and an else or with an if, else ifs, and an else, whichever you're most comfortable with. To use the original syntax it would be:[code] if (choice …

Member Avatar for ninjaneer
0
120
Member Avatar for abacian1983

You seem to have the big picture. Without knowing the specifics it appears that you are overwriting the boundaries of array called permutation. The values of i and j are to complicated to tell for sure. I'd suggest simplifying them. If permutations has N elements then the index of the …

Member Avatar for Nick Evan
0
234
Member Avatar for ranseed

>>Can anyone help me? Probably. The help you'll get will most likely be in guidance rather than actual performance. You need to be as specific as possible with questions and show effort at trying to solve the problem yourself. If you end up posting code be sure to enclose it …

Member Avatar for Lerner
0
81
Member Avatar for 1q2w3e

>>so im asking you to do this Sorry, that's not the way it's supposed to work around here. >> i dont know where to start That's an attitude we can work with. I'd start with a similar but simpler task. In particular I'd start with this. Using pencil and paper …

Member Avatar for Lerner
0
96
Member Avatar for Shaun32887

The >> will not work if the string within a given column has any whitespace in it. For example, column 1 is a combination of first name and last name separated by a space, column 2 is an address and column 3 is an ID number. If non of the …

Member Avatar for Shaun32887
0
212
Member Avatar for Nemoticchigga

If you're not into STL yet you can even do it the old C way in C++. Here's one untested idea how that might be done[code] char * data = NULL; char * temp = NULL; char input[256]; int lenInput; int lenData; while(indata.getline(input, 256)) { if(!data) { lenInput = strlen(input); …

Member Avatar for Lerner
0
114
Member Avatar for joshmo

You seem to be using dequeue() to empty a queue. Since queues are first on first off, how you empty the queue depends on how you add to it. If you always add at head then you will need to remove from the tail and visa versa.

Member Avatar for Lerner
0
156
Member Avatar for ar31an

Say the box started out like this: 1 3 5 4 2 * where * is the cute little box. Then it would be sorted if the numbers were like this: 1 2 3 4 5 * To check if the numbers are sorted in ascending order then use a …

Member Avatar for ar31an
0
142
Member Avatar for sniper29

Okay, here's a slight rework of your program. It does the bare bones initializing of the plane array and allows you to display the plane as many times as you want. Until you understand what's being done, and why, you shouldn't do one line more than this.[code] #include<iostream> using namespace …

Member Avatar for jephthah
0
406
Member Avatar for theUnspeakable
Member Avatar for ice661666

The type long double can hold up to 19 digits. If that's not enough you could declare your own data type/class. Call the new class BigInt or HugeInt or whatever and use a string, as suggested, to hold char representations the individual digits. Overload the math operator *, and maybe …

Member Avatar for tesuji
0
139
Member Avatar for sniper29

Lot's of things. My first tip, never write more than a few lines, and clearly never more than a single action, without compiling and testing. By doing that you would find that you are overwriting your array and getting junk. Be sure you can initialize all elements of the variable …

Member Avatar for VernonDozier
-1
270
Member Avatar for WesFox13

I'd add a private data member consisting of an array of 10 doubles to represent the possible coefficients of a polynomial. Then I'd get at least one constructor working and the tostring() method working so I could review/monitor results as I started to work on each of the other member …

Member Avatar for Alex Edwards
0
102
Member Avatar for faust_g

Since you appear to be using STL vector objects you don't have to bother with memory allocation, it's done for you by the people who implement the vector class. So a vector sized to 10 objects of type T initially would be: vector<T> myVector(10); The need to get the vector …

Member Avatar for Radical Edward
0
146

The End.