48,985 Topics
| |
Hi all, I am trying to create a class to serve as a customized cout class. Right now I have made some test code to see if I can do it. Right now I am trying to make it function just like cout, but later I will have it do … | |
[url]www.learncpp.com/cpp-tutorial/103-aggregation[/url] In the example given they state a department can have a teacher and if a department goes out of scope/deconstructs it doesnt destroy the teacher that was in that department. for example in real life departments at different school change names,get added,and get deleted all the time. Just because … | |
Why is this possible (in VS2009): [CODE] struct outer{ struct inner1{ void f(){ inner2 in2; in2.g(); /* no previous forward declaraction*/ } }; struct inner2{ void g(){} } }; [/CODE] ... but not this (???) [CODE] struct outer{ /* This line required to remove error: struct inner2; */ struct inner1{ … | |
i have to count three districts 1, 2, 3 whom said no and whom said yes, which i had saved it in notepad the three districts. i have to use the while loop. i was trying ifstream iFile; inFile.open("vote.dat") while(district1 == yes) { cout <<"the district 1 said yes: "; … | |
hey everyone, m doing an assignment on bouncing ball,my code below doesn't bounce the ball,it just makes it move when the enter button is used,what can I do to make the ball bounce? [CODE] #include<alloc.h> #include<graphics.h> #include<conio.h> #include<stdlib.h> #include<dos.h> void main() { int d=DETECT,m; initgraph(&d,&m,"H:\\tc\\bgi"); int l=getmaxx()/2,t=0; int x=1,y=1; int … | |
| The output I expected was: [ICODE]alpha beta[/ICODE] I used the following code: [CODE]#include<iostream.h> #include<conio.h> void main() { clrscr(); char choice[2][5]={"alpha","beta"}; cout<<choice[0]<<endl; cout<<choice[1]; getch(); }[/CODE] But this is what comes: [ICODE]alphabeta beta[/ICODE] Can anyone tell me what I did wrong? Thank you. P.S.:I know I am not using standard c++, but … |
Trying to do some basic "Game of life", but for some reason i'm getting some weird results, the code: [CODE]#include "stdafx.h" #include "stdlib.h" #include <iostream> using namespace std; #include "windows.h" const int V=30;//Vertical const int H=40;//Horizontal char A[V][H]; int ne=0; //Set all to dead void setDead() { for (int i=0;i<V;++i) … | |
I'm sorry as this coding language is not in C++, but it is very simlar to it. I basically trying to learn how it works if I have an example of this: [CODE]new NodeArray[] { {0,0,0,0}, {1,1,1,1}, {2,2,2,2}, {3,3,3,3} }[/CODE] I want an example of it working on how to … | |
I am trying to write a function that will compute GPA. [CODE]#include "Student.h" #include "ClassInformation.h" Student* setupStudent(){ string f,l,idNo; double gPoint=0; Student *studPtr1; studPtr1 = new Student (); cout<<"Enter first name "; cin>>f; studPtr1->setfirstName(f); cout<<"Enter last name "; cin>>l; studPtr1->setlastName(l); cout<<"Enter A number"; cin>>idNo; studPtr1->setaNumber(idNo); cout<<endl; studPtr1->setGPA(gPoint); return studPtr1; } … | |
Is it possible to put a gap in a class definition? IE: [CODE]class a; class b { private: a test; public: a getA(){return test;} }; class a { private: int i; public: a(int i):i(i){} a operator+(int o)const{return a(i+o);} }; class b continued?//what? how? { void outputA(){cout<<a;} };[/CODE] This is just … | |
I'm having trouble using the CreateFile() and WriteFile() functions. Here's the code I've written: [CODE]#include <windows.h> #include <iostream> using namespace std; int main() { char cData[6]; DWORD dwBytesWritten; cout << "Please enter a number: "; cin >> cData[1]; for(int i = 2; i < 5; i++) { cout << "\nPlease … | |
I would like to embed the python interpreter, but not in the way most other people do. I don't need to multi-thread unless it's necessary to do as follows... What I need is control over when execution happens. More specifically, I would like to use a python script to call … | |
HI there! So ive been looking around on how to reset the function clock() and the examples ive found have not worked, basically in my code i have to loops, the first i want to run for 15 mins then the inner loop run for one, so i assigned a … | |
compiler : visual c++ 2010 os : windows 7 64bits learning template and encounter some problem [code] template<typename T> void easyCopyImpl(T const &A, typename boost::enable_if_c< boost::is_array<T>::value>::type *temp = 0) { std::cout<<"this is array"<<std::endl; std::cout<<typeid(T).name()<<std::endl; std::copy(A, A + sizeof_array(A), typename std::ostream_iterator<T>(std::cout, "") ); } template<typename T> void easyCopyImpl(T const &A, typename … | |
Okay, so I'm new to C++ programming and am working on a simplified project to find Expected taxable income. The project states that I have to set SI, HH, MJ, and MS as const int variables equal respectively to 5700, 8350 11400, and 5700. const int SI = 5700; const … | |
Hey, I'm looking for an IDE with .NET capabilities, but not visual studio. As I need it to run off a flash drive. Any suggestions? | |
[CODE]class Cents { private: int m_nCents; public: Cents(int nCents=0) { m_nCents = nCents; } // Copy constructor Cents(const Cents &cSource) { m_nCents = cSource.m_nCents; } };[/CODE] will the copy constuctor still work properly if i had decided to implement it was follows [CODE]class Cents { private: int m_nCents; public: Cents(int … | |
I have no idea how this would be done, but how would I check the amount of line that exist in a text file. [CODE] #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ifstream myfile ("example.txt"); if (myfile.is_open()) { while ( myfile.good() ) … | |
Having trouble computing the number of occupied neighbors each cell in the array has. Any help would be greatly appreciated. [CODE] Array[rows][cols-1] Array[rows+1][cols-1] Array[rows-1][cols] Array[rows][cols] Array[rows+1][cols] Array[rows-1][cols+1] Array[rows][cols+1] Array[rows+1][cols+1] [/CODE] | |
Hi, I started with C++ development recently, and I think I'm ready to start building GUIs for my apps. I'm thinking about using Qt, since it is the most popular C++ GUI library, but the licensing is really confusing, and there isn't a lawyer nearby that understands software licensing who … | |
Hey guys I'm in 11th std and we are supposed to do a C++ project on a topic called FUNCTIONS.What are they? | |
Hello guys! Basically I have this basic homework, the program must check if the digit sum of one of the 3 inputted integers is equal to the difference of 2 others. So if A = 56, B = 33 and C = 22, the program should output 56, cause 5+6 … | |
[CODE]#include <iostream> #include <fstream> using namespace std; int underPopulation; // Any cell with less than <underPopulation> liviving neighbors dies. int overCrowding; // Any cell with more than <overCrowding> living neighbors dies. int minNeighborsToLive; // Any cell with <minNeighborsToLive> living neighbors lives. int reproduction; // Any dead cell with <reproduction> living … | |
I am trying to do remote function call in c++. The scenario is like this. There are two programs running say P1 and P2. P1 is trying to call a function implemented in P2. The program P1 calls a function using an object which will make a call to a … | |
I need to use the comm port to control an equipment. In order to get some initial information about the equipment, I need to "Send" and "receive" several commands to the equipment automatically at the beginning of the program. I've tried several Serial Classes from the internet, even the MSComm … | |
I've been working with an older programmer who's coding an IVR solution. It's running on Windows 2000 and is connected to a T1 (we have internet access) through the machine his code is running on. I've been trying to get him to request information from our main web server via … | |
Write a program that computes XN where X is a floating point number and N is a positive integer. The program informs the user that N must be positive if the user enters a negative value. Of course, XN = X * X * X * ... * X -------------------- … | |
Hi , Assuming I have a text file containing numbers , exp : 1_234 And i want to store 1 as int ID1, 234 as ID2. How can I skip underscore "_" ? ifstream infile; infile >> ID1 >> ID2 , ??? I'm still not sure Thanks . | |
[CODE]#include <iostream> #include <iomanip> #include <cmath> #include <fstream> #include <string> #include <vector> #include <cstdlib> using namespace std; /** Test case 1: test words that start with a vowel. When inputting the words air and ear, then outputs are airay and earay. Test case 2: test words that start with a … |
The End.