Beginners - January 2014 (Page 7)

Struct to Private Class?
 
So basically, last week our lab was to make a struct, public obviously. Now our instructor wants us to change it to a class. The problem is the the data has to ...
[4 replies] Last: Giblit is right about the output function (it is "Tell, Don't Ask"), b... (by LB)
working with nested vectors
 
Hi, I wanted to write a program that used nested vectors. The nested vector would contain the sides of the triangles of the outer vector. I am not sure how to h...
[3 replies] Last: Oh wait, I think I get it now. Thanks! (by heyyouyesyouiloveyou)
Can someone compile this for me?
 
I'm trying to make a function that can calculate a number raised to a power, but my console isn't loading so I can't see what it's doing. Can anyone check it fo...
[5 replies] Last: Actually, 0 0 is an indeterminate form, but in many cases, it's treat... (by long double main)
Separating Interface from Implementation (1,2)
 
Hey guys , I wanted to ask what am I doing wrong here first I tried to separate the interface here: //Gradebook.h #include<iostream> #include<string>...
[24 replies] Last: If the project tab is empty that means you have no project open ;) (by LB)
Nodes with char problem
 
I have a problem inserting char values in a node, i dont know the reason behind it but it doesnt save the characters at all, anyone know the reason?. type...
[4 replies] Last: You can't use == with arrays. If you have char arrays, you can use st... (by Disch)
by pukol
fstream: modify text file
 
I have a program that saves and append data in a text file. This is what a regular txt file would look like. -----info.dat----- //not included in the text f...
[no replies]
weird input skipping
 
Hey all!, I've made a class with will add fractions, but when I try to loop it in the driver code as shown below, it works great on the first iteration, but aft...
[3 replies] Last: That works like a champ too, thanks! (by bookLearnin)
next word of input
 
I'm curious about reading in a line of input until certain words are reached and then saving the NEXT word/number of input into a variable. How would one go ab...
[10 replies] Last: So this is what I have before even formatting output. #include <iost... (by heroicJ)
by jwilt
function problems
 
the program works fine when I comment out my "larger" and "smaller" functions, but when I try to use them it messes up my sum and average function outputs. ...
[3 replies] Last: Yeah changing it to I worked, Thank you! (by jwilt)
by MRich
Connect 4 Dropping Pieces
 
Hello, I am trying to write a program that resembles the Connect 4 game. One problem I'm having is finding the proper way to print the game pieces(x and o) int...
[3 replies] Last: It should be: for(int i = (WinSize + EXTRA_ROWS) - 1; i >= 0; --i) ... (by yulingo)
by jwilt
infile problem
 
when I read from the file I can not get a string to output. instead it skips the place the string should be and I do not get any of the other information in the...
[5 replies] Last: passing by reference worked. and I have not been taught pointers yet. (by jwilt)
frequencies in vectors
 
I am writing a dice game that rolls a dice randomly according to a users input of 1-10000 going into srand. I got through the part where I got the output of the...
[6 replies] Last: std:: just tells you where it comes from. He's explicitly stating tha... (by Stewbond)
by donjon
Difference
 
Hi! I'm new here... And i'm new in cpp programming! I'm sure you can help me here.. I do not understand the difference... ClassName::ClassName(strin...
[2 replies] Last: Hi! Great response, thank you very much. Cheers (by donjon)
how to transform a program into a call by reference
 
Hi, last time we had a homework where we should create 3 functions, one that fills an array (2d) randomly, the other one where we sorted diagonally the array an...
[3 replies] Last: Here: int Array ; {for (int i=0; i<M ; i++) for (int j=0 ; j<M; j... (by Avilius)
Changing double to int using casting
 
double newnumber=234999 int temp=(int)newnumber; cout<<temp; when I output temp I get 234998...can someone explain why?
[3 replies] Last: Thank you...I hadn't thought about that! (by eman2013)
Where is the Syntax Error?
 
Hello there, i'm starting my first C++ class and i'm having trouble finding the logic error and syntax error in my code. The programs purpose is to write a mad ...
[8 replies] Last: Hey thanks for all the help, I have my program working now, it may not... (by polarbear22)
Random arithmetic answers.
 
I'm pretty new to this, and I'm trying to make a simple quiz game. My code is compiling and running exactly how I want it too, apart from line 11(where I assign...
[3 replies] Last: Moved it to line 39 and it worked, thanks a lot guys :) (by Wolfej1994)
by alsade
memory lick
 
can some one plz tell me why theres a memory lick here?? #include <iostream> #include <string> using namespace std; class employee { char* name; unsigned ...
[4 replies] Last: To add on to what LB is saying... you should only delete what you all... (by Disch)
validating a string variable
 
I would like to make a simple function that accepts a string variable and tests it to see if it's in the form of ( number/number ) so that I can use it in a fra...
[2 replies] Last: I didn't realize that, thanks alot! (by bookLearnin)
by alsade
how to intialize char array with class method
 
i have a class employee which contain char array like showed in the code: class employee { char name ; unsigned int salary; public: void Init (??,signed i...
[1 reply] : Maybe something like this? class employee { char name ; unsigned i... (by Avilius)
January 2014 Pages: 1... 56789... 44
  Archived months: [dec2013] [feb2014]

This is an archived page. To post a new message, go to the current page.