49,761 Topics
| |
Good Afternoon, I want to convert this if-else statement to a switch statement. The if-statement is: int x; cout<<"GIve me an int and I tell you whether is even of odd "; cin>>x; if (x%2==0) cout<<x<<" is even."<<endl; else cout<<x<<" is odd."<<endl; | |
Good Afternoon, I'm having problems with this assignment that deals with loops that implements the continue statement. Can someone check the loops that I have implemented on Part B and Part C that must have the continue statement. Here is the code #include <iostream> #include <fstream> #include <string> #include <cstring> … | |
So, I'm using allegro game programming library. Before I move on to bigger and better things I wnat to get a handle on pointers. Specifically with things like structs, linked lists and maybe binary trees in the future. I posted a program that uses a linked list to keep tracks … | |
Good Afternoon, The program that I'm doing with function doesn't want to run, the error that pops out is: 'std::basic_istream<_Elem,_Traits> std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &,signed char *)' Here is the code and header file that I have so far: CPP FILE #include <iostream> #include <fstream> #include <string> #include <cstring> #include <cmath> #include … | |
This works fine. For any type I create (Example): BoxArray& operator -= (const Box& B); BoxArray& operator -= (const BoxArray& BA); BUT when it comes to my literal types like char's and strings and char*'s, I get Ambiguous overloads: StringArray& operator -= (const std::string& S); StringArray& operator -= (const StringArray& … | |
Hi, I'm currently trying to learn WinSock coding from http://johnnie.jerrata.com/winsocktutorial/ however when I compile my listening socket, I get 9 'error LNK2019: unresolved external symbol' errors. They all look to be the same function names that are used in the code prefixed with an underscore after the function name it … | |
Hi there. I've just written an extremely simple cross-platform wrapper for posix threads. I compiled it on unix and it compiles with no errors. The windows side... not so pretty. I'm using MinGW. gcc compiles fine but throws a couple of warnings at me (I'll explain in a bit.) g++ … | |
Here's the problem: I need to implement a stack as an adapter to a List class. I don't know what that means though! I've researched on Google countless times and still don't understand what an adapter is. All the examples I've seen point to using inheritance and then using the … | |
Hey when I don't template my classes, I can pass member functions to eachother normally. But when I template it, I get errors. The two functions are defined as so: CustomType& Delete(int Position); CustomType& Delete(T ValueToDelete, bool All = false); CustomType& Delete(CustomType ValuesToDelete); And Implemented like this: template<typename T> CustomType<T>& … | |
Hi, Is anyone familiar with this problem in BorlandBuilderC++: void Print(AnsiString Path){ Label1->Caption=Path.c_str(); } ... Print("C:\Directory1\Directory2\Music.mp3"); When I pass this string to Print(AnsiString) and try to display it in Label1, I lose all '' signs and text in Label1 looks like this : **"C:Directory1Directory2Music.mp3"** Why is this like that? Thank … | |
How can I do the following but easier? I'm templating a class but I want it so that if typename T is of a literal type such as a string or char, then it can use the following member-function. If not then it cannot use it. I've been using typeid … | |
These are the guidelines; 1. Create and initialize an array containing the following tax rates: 0%, 5%, 10%, 15%, and 20%. Create and initialize another array containing the following income amounts: 0, 10000, 20000, 50000, 100000. 2. Prompt the user to enter a gross income amount. Read the gross income … | |
Good Evening (in CET) to everyone. I am in need of a bit of help. I have the following cpp and.h files: dirmain.cpp #include "dirseq.h" #include <iostream> #include <algorithm> #include "dirseq.h" #include <string> struct IsEven { bool operator()( int i ) const { return i % 2 == 0; } … | |
Assume you are looking to buy a house in a new development.After looking at various models they are majestic,split-entry,and single-story.The builder gave them the base price and the finished area in square meters of the three models.They want to know the models with the least price per square feet.Write a … | |
**Dudearoo** *Useing Code::Blocks* Heys you guys! ive got a question, i want to know if its possable to read a file name like for example dudearoo.dat and output the name ive got an idea for it, just i dont know how to read file name not coded into the program. … | |
I've read that anonymous structs are a compiler extension and codeblocks allows them as long as -pedantic-errors are not enabled. My question is, since it is not legal in C++, what would be the legal equivalent of: typedef union XYZ { int Color; struct { BYTE X, Y, Z; }; … | |
Hello, I have been programming for a little while, but I wouldn't consider myself very novice yet. Yesterday I started a project but ran into difficulties with getting the position of the object (apply_surface(0,0,Ss,screen,&clip[0]); to change based on the key input because they are in different headers and stuff, so … | |
**Dudearoo** *useing Code::Blocks* Hey you guys! I've got an problem, i want to print the current time, simple as that. heres my Code. #include <iostream> #include <stdio.h> #include <time.h> using namespace std; int main() { time_t rawtime; struct tm * timeinfo; char space[50]; time (&rawtime); timeinfo = localtime(&rawtime); strftime(space,80,"Current Time:%h%m%p",timeinfo); … | |
Hey c++ maniacs out there ^_^ I need your help to edit this code. In such a way that this program can generate all prime numbers from 10000-50000. BUT it will still ask the user what limit he wants but the limit should be between the said default limit ( … | |
Hello guys, I need to develop my own peap protocol. I've found some source code to inspect, but i dont know how to compile it. In Linux? In Visual Studio C? Please help me. I'm getting so pressed :s Here is the source codes : client : http://www.codeforge.com/article/116327 server : … | |
Simple conversion between string and int. | |
So, I just did a fresh install of ubuntu 11.10, and am in the process of reinstalling gsl. For some reason, my old make file seems not to work, and am trying to figure out how to change it. Last time I had a similar problem, people in here were … | |
I have 3 objects in Open Inventor: a lamp, a desk, and a painting. I need to -be able to place them on each other, such as a lamp on a desk, and a painting on a wall, -the objects can't penetrate the walls and floors (which I have a … | |
How can I cast a class to another type? Example: class Point { Point(int X, int Y); }; Point A(10, 10); POINT P = (POINT)A; A = (Point)P; //I've tried: Point::Point(POINT P) : X(P.x), Y(P.y), Color(0) {} //Constructor. Point& Point::operator ()(POINT P) { if (X != P.x && Y != … | |
I'm supposed to create a virtual catalog, change color/texture of objects, and improve the camera control in Open Inventor. I think I understand the basis for changing the color of an object such as in http://www.mc3dviz.com/openinventor-forum/showthread.php?p=480 but I'm also supposed to be able to change a file as well. With … | |
Answer by true or false : a) There could be several function calls in a program. **True** False b) Function call can be placed wherever it is required, regardless of the function’s number of calls. **True** False c) There are no conditions on where to place a function prototype. True … | |
can someone explain me how it does not swap my nodes? void Library::sortList() { book *head = NULL; book *current = head; book *newBook; current = head; ifstream infile; infile.open("LibraryData.txt"); if (infile.is_open()) { while (!infile.eof()) { newBook = new book; infile.ignore(100,'#'); getline(infile,newBook->ISBN); infile.ignore(100,'#'); getline(infile, newBook->author); infile.ignore(100,'#'); getline(infile, newBook->title); infile.ignore(100,'#'); getline(infile, … | |
hi friends... The following code is for getting tables list from specific database from MySql... =================================================================== #include <windows.h> #include <iostream> #include <mysql/mysql.h> using namespace std; int main() { //connection params char *host = "localhost"; char *user = "root"; char *pass = ""; char *db = "prakash"; //sock MYSQL *sock; sock … | |
From where to start in making an application like Dropbox ? Exists any code snippets or some api ? If not possible in C++, C# is good ... Thanks :D. | |
// this is the code i have so far. // please lend a hand on this please w your ideas// #include<iostream> #include<string> using namespace std; const int SIZE=50; main(); { ifstream inFile; float Grades[SIZE]; int SumOfGrades[SIZE]; int index 0; index 1; index 2; index 3; index 4; index 5; index … |
The End.