49,766 Topics

Member Avatar for
Member Avatar for ahtaniv

[CODE]class A { public: int a; A() : a(100) { } }; class B : public A { public: int b; B() : b(200){ } }; int main() { A a; B *ptrB =(B*)&a; cout<<ptrB->b<<endl; // Is there a way to get this to print 200?? }[/CODE]

Member Avatar for ahtaniv
0
276
Member Avatar for c++probeginner

[QUOTE] I'm having trouble getting the player's name and score to display as well as the average score. I have been at this for about 3 hours. I think it's time for a fresh set of eyes. Can someone please help?! This assignment is due tomorrow. Thanks [/QUOTE] [CODE]#include <iostream> …

Member Avatar for kimmyfufu
0
191
Member Avatar for Shadbanks001

Im in dire help of needing to do the following: 1. Write a function which will take a grade as an argument and validate it for domain (in a valid range). Return true if valid, false if not. 2. Write a function which will take a grade as an argument …

Member Avatar for sfuo
-2
395
Member Avatar for iamthesgt

In my program that uses separate compilation, the only problem I have left is a linker error. To see if it was just a syntax error somewhere obscure, I made a simple "hello world" program that uses separate compilation. I get the same error. The code is below. If someone …

Member Avatar for iamthesgt
0
629
Member Avatar for zidane010h

hey guys,I'm soo beginner in C++ :$ .could you please explain logic of the loop [CODE]#include <iostream> using namespace std; int main() { int x = 0, p = 5; while(x < p) { for(int i = 0; i < x; i++) { cout << "+"; } cout << "\n"; …

Member Avatar for zidane010h
0
216
Member Avatar for SacredFootball

I think the code comments show what is needed. Essentially, I just need to spit out the members name and score who are below the average score in the list. [CODE] void displayLowScore(struct payload *arrayStart , //first element of array struct payload *arrayEnd ) //last element of array { int …

Member Avatar for SacredFootball
0
156
Member Avatar for Jutch

I have this assignment for school due tonight but I can't figure out the two errors causing problems for me. I've asked my class, I've asked twice on yahoo answers and I still don't understand what to change. If someone can please show me the exact changes that need to …

Member Avatar for Jutch
0
202
Member Avatar for eduard77

I have a vector defined like this: [CODE] #include<iostream> #include<vector> using namespace std; typedef vector<int> VECTORINT; int main() { VECTORINT Vectorul; int x; int num; int y; cin>>num; //the number of numbers that must be entered for(int i = 0; i<num; i++){cin>>x; Vectorul.push_back(x); for(int i=0; i<Vectorul.size(); i++) cout<<Vectorul[i]<<endl; } system("pause"); …

Member Avatar for eduard77
0
113
Member Avatar for rcmango

Hi, well I have written something that compiles and runs fine with a different compiler, but when trying to use a g++ compiler, I get errors when compiling in a unix environment. Here is the command line I have used: [CODE]g++ Agent.h Agent.cpp Driver.C g++: Compilation of header file requested. …

Member Avatar for Akill10
0
118
Member Avatar for HeartBalloon

Hi, I have to write a code which should allow to append and item to a list. That is FIFO Logic, First In First Out, but I cannot think of anything of that kind actually. I mean, I should run the list until the last pointer, and then make it …

Member Avatar for HeartBalloon
0
638
Member Avatar for Violet_82

Hi there, I am doing an exercise from a c++ book, but I get few errors that I can't seem to be able to fix, and I am not quite sure why. The exercise goes:" In a right triangle with dimensions side1, side2 and hypotenuse, find all Pythagorean triples for …

Member Avatar for Violet_82
0
897
Member Avatar for BlueZephyr

Hey everytime I run this it outputs the else of neither no matter what I enter. And I checked my conditions and the logic seems right but maybe I'm wrong. Help please! [CODE]#include <iostream> #include <cmath> using namespace std; int main(){ int n1, n2, n3; cout<<"Enter the three sides of …

Member Avatar for BlueZephyr
0
95
Member Avatar for HeartBalloon

[CODE] int findWord(char ma[][iSize], char ca[],int iRing,int& X, int& Y){ int ring=0,i=0,j=0,x=0,y=0,k=0,i2p=0, iLSide=0,iSSide=0; bool bOkay=true, bOver=false; ring = iRing--; iLSide=(iSize-(ring*2)); iSSide=(iSize-((ring*2)+3)); i2p=(iLSide*2)+(iSSide*2); x=y=i=ring; while(i>=ring && i<i2p && bOver==false){ j=i; switch(i){ // WHAT'S WRONG WITH THIS?!? WHY CAN'T I ASK A CASE MINOR OR EQUAL? case =< iLSide: x=ring; y=j; break; …

Member Avatar for HeartBalloon
0
176
Member Avatar for peck3277

Hey guys, I'm looking for some help in a project I'm undertaking. I have an AVR micro-controller sending data to my pc via the COM port. I want to write a c++ program, that will listen out for any data coming from the COM port and to write that to …

0
59
Member Avatar for lochnessmonster

im just curious on the purpose of pointers to pointers and when i would actually ever find the use of using one! thx

Member Avatar for Ancient Dragon
0
95
Member Avatar for smokin745

hello guys, i want my code to display the raw image "texture.raw", and at the same time, display a flashing text exactly besides it in a seperate viewport or with some other way. Please help me with this, as this code doesnt do that, it just flashes the image and …

0
92
Member Avatar for Nandomo

I want to use Ncurses on Dev-Cpp but don't know how to install it. I have downloaded the ndk for it, any help?

Member Avatar for Ancient Dragon
0
102
Member Avatar for marciaalanna

I am trying to finish this program that is due tonight. I have been working on it through out the week and thought I could figure out my errors with fresh eyes. I have got the number of errors down, but for some reason I keep getting errors like string …

Member Avatar for marciaalanna
0
105
Member Avatar for iamthesgt

This may be a simple fix, but I have a class for a program that contains some member functions that manipulate a vector. The vector is a private member variable, and is filled from an array using a constructor. When I try to access the member functions to manipulate the …

Member Avatar for iamthesgt
0
175
Member Avatar for ERadu

Hello! I am having some trouble with reading data for a list. If at the end of the file there is a new line character, this function reads the last set of data again, and then exits the loop. The addElem function works fine, I tested it separately. As there …

Member Avatar for arkoenig
0
290
Member Avatar for begineer

hi guys. i want a help on making directories in c++.i have used the code to declare and intilliaze the path name and folder name..but the probelem is that i want it to to ask from the user for the drive and folder name..i tried but i didnt get the …

Member Avatar for Ancient Dragon
0
208
Member Avatar for emreozpalamutcu

I have made a program using C++ Windows Form Applications and I don't want my program to run more than once. What is the code for this?

Member Avatar for Dingbats
0
110
Member Avatar for smokin745

Hi guys, I am doing a project wherein i have to make an OpenGL animation and its a Sainsbury advertisement and it kinda sucks till now. Now i really need to add images, viewports and be more creative. Following is the code till now, (yeah laugh at it...it sucks more …

Member Avatar for smokin745
0
192
Member Avatar for chamnab

Hi anybody do you know how to limit string that we input in the program ? LIKE THIS: Input Name: <-we can input only 5 characters

Member Avatar for jonsca
0
94
Member Avatar for jaepi

Hello, there. I'm having trouble with the initialization of variable of type sem_t. I used this. [code=c++] sem_t example; example = NULL; if(example == NULL){ /* code here */ } [/code] I'm getting the error, "no match for operator ==". What value do you think I should place in the …

Member Avatar for sfault
0
633
Member Avatar for glenn_boy13

hello there! I am new here on Daniweb. I couldn't find an article anywhere on google about moving text in C++. I have an idea but my problem is, I can't find a way to make my other output still. What I mean is: I don't know how to prevent …

Member Avatar for Mouche
0
1K
Member Avatar for Asif_NSU

Hi there C /C++ experts... I have a confusion regarding the function free(void *) in C and [I]delete[/I] in C++. Suppose there is a pointer named p. In C++, we dynamically allocate memory for p to point at like this [CODE] p = new int [10]. [/CODE],then when we use …

Member Avatar for ahtaniv
0
789
Member Avatar for wondernaet

I just posted this broken. Here is the code that works. I was told there is 2 ways this can be written more efficient. I can't see it, can you? #include <iostream> #include <string> using namespace std; void daysOfChristmas (int days, char switcher, string b[12]){(days > 0 && switcher == …

Member Avatar for VernonDozier
0
115
Member Avatar for iamthesgt

When writing a program that uses separate compilation (I have a header file, a .cpp file that declares all the member functions of the class in thee .h file, and an application file). I used a constructor to pass the contents of a dynamic array to a vector, but it …

Member Avatar for iamthesgt
0
287
Member Avatar for triumphost

Note: I program in C++ Not C#. In visual studio 2010, Where u press release or debug, next to it has a box with win32.. How can I change it to x86.. I tried pressing New and edit and stuff and configuration manager but it doesnt have the x86 choice... …

Member Avatar for Ancient Dragon
0
383

The End.