Search Results

Showing results 1 to 40 of 958
Search took 0.05 seconds.
Search: Posts Made By: firstPerson
Forum: C++ 45 Minutes Ago
Replies: 4
Views: 46
Posted By firstPerson
Why do you have 3 loops for a 1d vector?

If you want to emulate it as a 2d then all you need is 2 for loops.


int A[4] = {1,2,3,4};
int B[4] = {1,2,3,4};
int R[4] = {0};

for(int i = 0; i...
Forum: C++ 11 Hours Ago
Replies: 6
Views: 88
Posted By firstPerson
use SingletonVector::vBooks.push_back(b);
Forum: C++ 12 Hours Ago
Replies: 1
Views: 83
Posted By firstPerson
Tell me if you see a problem here :

char an;
cout << "Please enter the operation you want" << endl;
cout << "Press 1 for addition" << endl << "Press 2 for subtraction" <<
endl << "Press 3 for...
Forum: C++ 12 Hours Ago
Replies: 6
Views: 88
Posted By firstPerson
>>a problem arises whereby, when I access the vector from a different class, for some reason it "loses" it's contents and is empty?
<<

From what content?

How about you make a adapter class,...
Forum: Game Development 1 Day Ago
Replies: 1
Views: 121
Posted By firstPerson
You could use glutBitmapCharacter (http://www.opengl.org/documentation/specs/glut/spec3/node76.html)

Combined with function you can make this :

void renderBitmapString(
float x,
float y,...
Forum: C++ 1 Day Ago
Replies: 3
Views: 115
Posted By firstPerson
Here is a hint :

********** 10 stars
********* 9 stars
******** 8 stars
******* 7 stars
****** 6 stars
***** 5 stars
**** 4 stars
*** 3 stars
Forum: C++ 1 Day Ago
Replies: 3
Views: 84
Posted By firstPerson
Well the top and the bottom are the same so you can just duplicate the
top at the end, and the middle two are the same. I see no reason to
use for loops for this.
Forum: Java 1 Day Ago
Replies: 7
Views: 118
Posted By firstPerson
>>or some reason it doesn't think accountSum has been initialized so my program won't run
<<

Yea its right, sorry I am in c++ mode.

try :

Account accountSum = new Account();
Forum: Java 1 Day Ago
Replies: 7
Views: 118
Posted By firstPerson
>>
Add a static method Account consolidate(Account acct1, Account acct2) to your Account class that creates a new account whose balance is the sum of the balances in acct1 and acct2 and closes acct1...
Forum: C++ 1 Day Ago
Replies: 14
Views: 241
Posted By firstPerson
Post your code as of now.
Forum: C++ 1 Day Ago
Replies: 5
Views: 122
Posted By firstPerson
call your calc_average inside openFile function.
Forum: C++ 2 Days Ago
Replies: 7
Views: 212
Posted By firstPerson
Ascii Table...
Forum: C++ 2 Days Ago
Replies: 14
Views: 241
Posted By firstPerson
>>xutility(348) : error C2064: term does not evaluate to a function taking 2 arguments

Which line is this from?
Forum: C++ 2 Days Ago
Replies: 14
Views: 241
Posted By firstPerson
recordsList.sort(compareForSort);


Try this :

recordsList.sort(&Standings::compareForSort);
Forum: Java 2 Days Ago
Replies: 7
Views: 149
Posted By firstPerson
Yea, sometimes, but IMO not all the times. It depends on the variable
name. When giving a variable name, if giving it isBlah doesn't
necessarily make sense, for example, suppose you have a state...
Forum: C++ 2 Days Ago
Replies: 14
Views: 241
Posted By firstPerson
You cannot use std::sort with list (if that is what you intended to do)

list has its own sort. Here is an example : http://www.cplusplus.com/reference/stl/list/sort/
Forum: C++ 3 Days Ago
Replies: 3
Views: 130
Posted By firstPerson
I am a little doubtful about your code. Why does CarNode inherit from
Car and it also composes it ?

Note that in c++ objects is by default passed by value and Not passed by
reference. You may...
Forum: C++ 3 Days Ago
Replies: 1
Views: 110
Posted By firstPerson
Your copy ctor is hiding the member variable. And even worse you have
a memory leak.
Forum: C++ 3 Days Ago
Replies: 1
Views: 84
Posted By firstPerson
Then you should take the input as a string. Then if the size of the string is
greater than 1 then display an error message, else compare it with a or b.
Doing this way you would have to use...
Forum: C++ 4 Days Ago
Replies: 4
Views: 136
Posted By firstPerson
Let me try to explain further of the algorithm below :

An outline of the above algorithm would look something like:

// positive integer I is given
P = 1 //determines when a even factor of I is...
Forum: C++ 4 Days Ago
Replies: 3
Views: 123
Posted By firstPerson
You need to use the mod operator.

example :

2 % 2 = 0
4 % 2 = 0
12 % 2 = 0
114 % 2 = 0
Forum: C++ 4 Days Ago
Replies: 9
Views: 142
Posted By firstPerson
Like super-sonic said, you need to pass your variables.

This code :


double distance()

{

double center1, center2, point1, point2;
Forum: C++ 4 Days Ago
Replies: 7
Views: 211
Posted By firstPerson
>>
I'm trying to eliminate the highest and lowest number out of 5 inputs then get the average of the remaining 3 inputs...
In some instances, it gives me incorrect average..
<<

First find the...
Forum: C++ 5 Days Ago
Replies: 8
Views: 169
Posted By firstPerson
>> result = ((x % 10) + ((x / 10) % 10) + ((x / 100) % 10) + ((x / 1000) % 10) + ((x / 10000) % 10));

You know your formula won't handle number above 99999, try
doing this with for loops or...
Forum: C++ 6 Days Ago
Replies: 20
Views: 301
Posted By firstPerson
Yea, to show that initializing variable should become a habit for it
will save bugs from appearing when working on bigger projects.
Forum: Java 6 Days Ago
Replies: 11
Views: 319
Posted By firstPerson
>>last 15 years
Wow, I have just programming for about 2 yrs on/off so you have a lot more knowledge than me. Nevertheless I would still like to debate even though if I may be wrong, if that's OK...
Forum: C++ 6 Days Ago
Replies: 3
Solved: Array sort
Views: 128
Posted By firstPerson
Use the suggestion above, although you might want to google sorting for knowledge experience.

You can do this if you want to use std::sort;

#
int main()
{
int x[5];
prompt(x);...
Forum: C++ 6 Days Ago
Replies: 20
Views: 301
Posted By firstPerson
>>(By the way, what does "if (! cin)" mean exactly? I copied yours but not sure the exact function of it. Can you put the "!" in front of any statment?)
<<

First realize that "cin" is a istream...
Forum: C++ 6 Days Ago
Replies: 12
Views: 178
Posted By firstPerson
what do you mean "it doesn't want to"? Does it give some errors?
Forum: Java 6 Days Ago
Replies: 11
Views: 319
Posted By firstPerson
>>
"what guarantee do you have that you are actually comparing values in c++?"
<<

In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at...
Forum: C++ 6 Days Ago
Replies: 20
Views: 301
Posted By firstPerson
Then make another test case for floating point,

float temp = 0;
int val = 0;
cin >> temp;
//check for non number character error

int val = int( temp ) ; //get the whole value

if( val <...
Forum: Java 6 Days Ago
Replies: 11
Views: 319
Posted By firstPerson
late reply but its just preference at times.

A thing to note ( at least in c++) is that != is more generic than
'<' because '!=' works with containers like vectors, string map
while '<' is not...
Forum: C++ 6 Days Ago
Replies: 20
Views: 301
Posted By firstPerson
If you need only whole value integers. Then use a typecast on float and use that whole value.

float f = 12.33;
int i = int( f ); //i = 12


Then work with 12
Forum: C++ 6 Days Ago
Replies: 12
Views: 178
Posted By firstPerson
Oh right, its your conditional expression thats giving you problems :

if (mybmi < 18.5) {
}
else if (mybmi >= 18.5 && mybmi <25) {
}
else if (mybmi >= 25 && mybmi < 30){
}
else if (mybmi >=...
Forum: C++ 7 Days Ago
Replies: 8
Views: 149
Posted By firstPerson
Then just do this :

void assign_struct(A test[], int id)
{
switch(id)
{
case 0 : A[0].a = 12;
case 1 : A[0].a = 2;
case 2 : A[0].a = 1
//so on
Forum: C++ 7 Days Ago
Replies: 12
Views: 178
Posted By firstPerson
>>Thank you so much. Now I have another problem. The only 2 messages it wants to print: the underweight and normal one.
Is it possible to do a range for these?

What do you mean? You only want the...
Forum: C 7 Days Ago
Replies: 2
Views: 127
Posted By firstPerson
You mean the input is something like this ?

<enter fraction > 123/452


And its read as a string.

If so then separate the string into 2 components the left side before the '/' character...
Forum: C++ 7 Days Ago
Replies: 8
Views: 178
Posted By firstPerson
because thats still returning a value;

cout<<"A", mean A goes into the stream and then cout is returned .

with your :

a == 1 ? return 1 : return 0;

does not return a value for that...
Forum: C++ 7 Days Ago
Replies: 12
Views: 178
Posted By firstPerson
Your problem is that your are eventually doing :

cout<<cout;

which is print the object's address.

For example :

if (mybmi < 18.5) {
cout << "\nYour BMI is:" << mybmi << cout << "\tYour...
Forum: C++ 7 Days Ago
Replies: 2
Views: 92
Posted By firstPerson
What type of converter ?
Showing results 1 to 40 of 958

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC