General C++ Programming - February 2012 (Page 41)

by homsta
How do you get a certain element like "5" of a list?
 
I can't find anything about getting a certain element of a list. I have a get_elem() function that takes in an int, meaning if the int was "5" I want to return ...
[3 replies] Last: Thanks to both of you! (by homsta)
by homsta
Two "seemingly" similar pieces of code and need help
 
So I have pasted the two functions below that I'm getting issues from. The top one works fine, but for some reason the bottom one gives me an error for the "=" ...
[2 replies] Last: Thank you that was it. Kinda stumped on my function though. Do you kno... (by homsta)
how to determine what type of content does a file contain?
 
i have to create a program to isolate string, float and integer values in a file that may be located randomly in the file. how do i determine it?
[3 replies] Last: I would just do a search of the string. http://www.cplusplus.com/refe... (by roberts)
I'm having trouble with an ambiguos operator.
 
I declared to overloaded operators, '='. One takes unsigned long, the other takes a double. Now the problem is the compiler can't tell which function I want ...
[2 replies] Last: It tried to put 0L but it still does not understand. I even tried (uns... (by coercedman66)
Two class defintions that both reference each other.
 
class firstclass { firstclass& returnplusclass(Secondclass second) { //plus logic goes here return *this; } }; class s...
[3 replies] Last: The forward declartion solved my problem. Thank you. (by coercedman66)
by axtroz
How to check if a variable is initialized?
 
Greetings, I have the following situation: class AbstractSCP *scp; doConnect(scp) {...} // this function is NOT called, it just exists to establish a connect...
[2 replies] Last: I managed to workaround with a constructor that doesn't require argume... (by axtroz)
pure virtual enumerations?
 
Is there a way to make a pure virtual enumeration? If not, any suggestions how I could get a similar effect? Here is the code I'm working with: #include...
[4 replies] Last: Thanks for the responses. Sorry I wasn't more clear L B, I understand... (by skrug80sc)
getline
 
I have the following line: %b02_a08 b02_a08_counts b02_a08_eu But when I use "getline" I get: %b02_a08_TALOb02_a08_countsb02_a08_eu as a return for ...
[no replies]
by bdp10d
Enter a Year Print out a calendar
 
we are given an algorithm a=(14-month)/12; y=year-a; m= month+12*a-2; startday=(day+y+y/4-y/100 + y/400 + (31*m/12))%7; I think I underst...
[no replies]
by Canvas
SDL wrong draw a image
 
Hey there guys. Ive just started to learn SDL, and im having a bit of a small problem, im following this tutorial http://lazyfoo.net/SDL_tutorials/lesson...
[3 replies] Last: That's because it's looking in different directories. When you run ... (by Disch)
program to add Elements above and below the main diagonal in a matrix
 
This is my program written to read, print a martix into it and then print the sum of the elements above & below the main diagonal. I hope this is correct. Plea...
[3 replies] Last: Thanx danoc 93. appreciate your tym and info with which u provided me... (by absawis)
File names from Input File
 
I have an input file (input.txt) with several file names (*.dat) listed on each line. I need to get C++ to read from the input file (which I can open) and open ...
[1 reply] : I'm also using getline() to read from the data files, so I bet it won'... (by pbhuter)
by jmrag
Class equality check
 
Is there any way to check if A==B within a function?? Class A{ public: int id; string description} Main() { Class A a; a.id=5; a.string="hel...
[12 replies] Last: I understand now, Gaminic. Thanks again :) Wazzak (by Wazzak)
Managed string to hex
 
Hi, I've got a managed string that contains chinese characters from a file. The file was UTF-16LE encoded. I'm trying to convert the managed string into he...
[1 reply] : I think all encoders have the GetBytes() method. Use that. (by webJose)
Return vector of struct from function
 
I have a structure struct MYSTRUCT{ int index; char* name; }; I have a function with this declaration vector<MYSTRUCT> get_vector() { vector<...
[8 replies] Last: Problem solved. I had to add using namespace std and the #include di... (by alexbnc)
by jmrag
Clone a class without copy constructor
 
Is there any way to create a class through a function that its scope is in the outside?? To be clear i have this Class A{ public: int id; //f...
[5 replies] Last: Want a friend? class A { public: friend A Clone(); ... (by Wazzak)
Maybe a "noob" question
 
Well im just starting out on the C++ scene and for an assignment i have to program a small C++ game. So i went for the generic Text Based RPG and planned on imp...
[7 replies] Last: Damage = rand() % 9 + 1; If that is in the for loop as well, it'l... (by Gaminic)
Arrays
 
I have several text files of columns of data. Some have three columns, some have four. All of the columns have headers on them. I need to be able to break each ...
[7 replies] Last: hamsterman: I'm going to be going through the data, doing some interp... (by pbhuter)
by gomsi
HOW TO OPEN A FILE USING OPEN()
 
I tried MAN page for open.. but didn,t got idea ..please help for the same.... in c++
[2 replies] Last: i want to open a file /dev/sda and show its content using open functio... (by gomsi)
How did YOU learn C++? (1,2)
 
Hello members of Cplusplus forums. I am planning on learning C++ programming from a book, but am a little intemidated by it. The book is called C++ Primer P...
[22 replies] Last: I had a class of Java at one point, but the level was pretty low (Thin... (by Gaminic)
February 2012 Pages: 1... 3940414243
  Archived months: [jan2012] [mar2012]

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