49,757 Topics
| |
Say you have a class that has members [code] private: double a,b,c,d,e,f,g,h,i; [/code] You can make an accessor like: [code] double operator[](int index) { if(index == 0) return a; else if(index == 1) return b; else if(index == 2) return c; } [/code] But how would you do something like … | |
Hello again, I'm having trouble with a program that I have to write involving classes and arrays. Essentially i have to create a class Theater, which I am not sure how to do. The theater has 15 rows with 30 seats per row, and each row is assigned a price … | |
this is a simple example of a problem I have been having with differing programs, i am using linux ubuntu 9.10 and codeblocks 8.02 . this is the code [code] #include <iostream> using namespace std; int main() { int hiya; cout<<"hello world \n"; cin.get(); cout<<"enter a number \n"; cin>>hiya; cout<<"you … | |
I wonder if anyone can tell me how the code tags works? As per my understanding does it works like: [CODE]MY CODE HERE.....[/CODE] for the enitre block of code? or I need to do this for every line of code? | |
Hi, I've just started with c++ and I have no clue how to do this. Right now I have a code that just printing out the text lines in my file and how many lines there is just to check that i can read from my file... But what I … | |
I decided to try Visual Studio 2010 express Beta 2. This code works fine on my other computer that uses Visual Studio 2009 Pro. I am going to make a Timer that count down from a fixed time depending on foodsource. But first this code need to work :P so … | |
Hello All ,This is me again :icon_mrgreen: I'm Making a programme which tell the user to input the name of the product he wants to show its Price and Amount ,but i have a problem: Here's The Code [CODE] #include <iostream> #include <conio.h> using namespace std; struct Shop { int … | |
Hello All, I am creating the array of size: 26627664 bytes then convert the byte to char array. While deleting the array i got an code gaurd log error that Bad Parameter. I am doing like this Char* pBuffer = (Char*)new BYTE[26627664]; and deleting like this, if(pBuffer != NULL) delete[] … | |
The code below runs fine but I want some help how can I get output of my original input and reverse of that i.e. ABCDE Z. WXYZ ---> EDCBA .Z ZYXW The below is the code for this. [CODE] #include <iostream> #include <cstring> using namespace std; void swap(char& a, char& … | |
Hi all, This is me again ,I want to learn programming in ASP.NET using C++ I've installed the IIS ,and made an .aspx file with the following code: [CODE]<%@ Page Language="C++"%> <html> <head><title>Welcome!</title></head> <body> <p align="center"><font color="RED" face="Snap ITC" size="12pt">Welcome to your New ASP.NET Page <br> "Using C++"</font></p> </body> </html>[/CODE] … | |
Hi, some time back i faced question like this. we ca use factory design using factory desing implementation. we can do the same using the shared laibrary, like we will have a static function in the shared laibrary which will be returning pointer to base class object. what is the … | |
so i guess there must be some sort of an error in my logic but on line 119 i started a counter that only goes up when a pair is made in the game. Since there are a total of 8 pairs, i set that when the counter is 8 … | |
Hello everyone; I did a program using arrays -for the first time- I've got errors, I fixed some and there are others left that I couldn't straighten any help is highly appreciated here is the code : [CODE]# include <iostream> # include <iomanip> using namespace std; int read_car (int cars[], … | |
I have been writing a program using arrays and strings.Here is my question. A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In "tests.dat"Each record of which consists of a student id, followed by a blank, followed by students 20 responses. … | |
Can someone please explain the concept behind bubble sorting a vector step by step? I know this is a tedious task so whoever answers I will much appreciate it! :) Questions: 1.) What variables are being used? 2.) How and where is the function placed? 3.) Where and why are … | |
I'm making a project in Visual studio 2008. The details of the project are: - It is a MFC Application - The application type is Dialog based with Use HTML Dialog enabled - The project style is MFC standard and... - The use of the MFC is in a shared … | |
Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute. Overload extraction and insertion operations for the class. Overload the == operator to compare two PhoneCalls. Consider one PhoneCall to be equal … | |
this is the output when enter 1 *********O* when enter 2 ********O** ---------------------------- 1*********O* 2********O** 3*******O*** 4******O**** 5*****O***** . . . . . . . help me plss tnx | |
So i need help figurin out where my segmentation fault is comin from. Im not even close to finishing this program but i was just testing my progress so far to make sure that it was taking values correctly, but sometimes the program doesnt stop when its supposed to and … | |
Hi all, I'm new to working with C++ (I'm more a C programmer) and I have a question: I have a container class for a templated type T, which could be any scalar type, although the most commonly used ones are unsigned char and float. I have a function that … | |
I've been studying VC++ for about 2 months, and I was working on my first game from a book (Game Programming All In One) The game is 'Craps', it's a dice game. Anyways, I've had a few prolems with the codeing, can someone help me? (Windows 32 Console) Here is … | |
Pseudocode is still somewhat confusing and I've been reading and this assignment for the a while now and I wanted to make sure I am understanding what's being asked of me. Could someone please tell me if my pseudocodes are correct? Question: 1. Using pseudocode declare a Real number named … | |
hello i have given a program which uses the class. It reads the date of birth. And do all the necessary checks on the given value. e.g. What is the limit of that particular month, whether it is a leap year or not. I am writting the first program using … | |
I recently needed to add member functions like these into my class [CODE]istream& read(istream&) ; ostream& print(ostream&); [/CODE] I am a little confused on how to actually call these functions within my class. I am more familiar with overloading the insertion and extraction operator since the prototype for those makes … | |
My program deals with the Genetic Algorithm and Hill Climber Algorithm. I have a program that compiles without any errs, its just the data is gives is incorrect. I explain my error on the bottom part of my post Header File [CODE]#include <iostream> using namespace std; //------------------------------------------------------------------------------ template<class T> class … | |
Hi everyone!! I am Kevin, and I am new to this site. I am taking C++ classes and have trouble writing this program. I know I have to use several "for" loops and "rand" commands to write it but i am not exactly sure how to do that?? so, please … | |
cout<<"hello,everybody!"; Can somebody come for the rescue? Please *My_problem(Is writing a fuction that divides two polynomials ) { return rescue; } | |
Please ok can any one give me the code to this im making a program and it needs this and im stuck please give code asap application that will convert any text I throw at it to hex Thank You | |
Good morning all, So i have started teaching myself C++ in preparation for taking software engineering at university next year, after many hours i have managed to put a simple program together, Im just asking if someone can tell me on in the right track to understanding what each function … | |
I have a project that requires me to make a search engine for classes. If i were to enter Biology, then classes such as genetics, chemistry, anatomy and physiology are to show up. But the thing is i have the classes and their descriptions in a file and i was … |
The End.