General C++ Programming - January 2016 (Page 11)

Cannot initialize "BaseClass **" with an rvalue of type "DerivedClass **"
 
Here's my code: Bird *polly = new Bird(); Animal **pollyPtr = &bird; The previous line is giving me the error in the title. Please tell me how I fi this. :)
[2 replies] Last: > Cannot initialize "BaseClass **" with an rvalue of type "DerivedClas... (by JLBorges)
by Kubani
Defining operators for vectors of templates
 
I'm reading Programming Principles and Practice Using C++ first edition first printing book. This book is really hard for beginners but I have studied it unti...
[15 replies] Last: Yes and what is question for me is that why the author (the creator o... (by cire)
how to insert pair values in a map into a normal map
 
So if I have a map m1 that has pairs of <string,pair<string,int>>, how do I 'extract' the value of m1's pairs and put them into a new map m2 so that I have norm...
[1 reply] : Maybe something like this: for (std::map<string,pair<string,int>>... (by Chervil)
Is it OK to make node struct public within stack class?
 
I wrote a stack data structure. It is a series of nodes . Each node has a value, and a pointer to its parent node...and child node. Is it bad to make variabl...
[5 replies] Last: Yes Doug, all of your assumptions about my stack were correct. Much s... (by niko79542)
Question about the rand() function
 
Hello. I want to make a program that, given the minimum value and the maximum value, generates a random number within that range. I made that with this co...
[13 replies] Last: It returns the rest of the division btween rand() and what comes after... (by gedamial)
Linked List questions
 
So far I've made a linked list with relatively little help, which is why I now need it. My linked list "works" but to me doesn't look very efficient. For instan...
[2 replies] Last: Well I'm using the pointers for the list. And yeah, now that I think a... (by rabster)
C== chat application
 
hi. i have been doing a c++ client server chat application with exceptions . but when i run the server code the system breaks. how can i fix it? here is the c...
[5 replies] Last: is this server code ok? #include <winsock2.h> #include <ws2tcpip.h> ... (by saramarikar)
dereferencing question (1,2)
 
Leading up to the question, this example shows simple dereference: value foo = 500; int * n_ptr = &foo; cout<<*n_ptr; 500 Below, what does (*n_ptr) der...
[22 replies] Last: but also a struct as well. The struct having public member access by... (by MikeyBoy)
problem regarding files
 
i am working on my c++ school project. i have a problem in that. i have a class with 3 char data members. while writing to a file, the first 2 are written and t...
[2 replies] Last: The clairvoyants are off duty now. Can you show the code so that ordin... (by Thomas1965)
static variables
 
how to use static variables?what is the point of using it?
[3 replies] Last: Storage class specifiers http://en.cppreference.com/w/cpp/language/sto... (by closed account E0p9LyTq)
Help Debugging (1,2)
 
#include <iostream> using namespace std; int main() { char response; cout<<"You enter a dark hallway deep under ground..."<<endl; cout<<"///...
[23 replies] Last: Yes, I had a sick day from school and I got bored and had the idea lol (by YvngSavage)
how to make my function accept both const char* and string
 
I have a function in my class: Serial::Serial(std::string* portname) { file.open(portname->c_str()); } do I have to write this function 2 times to m...
[7 replies] Last: With modern C++, with move semantics, passing a string [by value] doe... (by Peter87)
by abc1
Sorting
 
Which of the following sorting algorithm is of divide and conquer type? A) Bubble sort B) lnsertion sort C) Quick sort D) Merge sort Please help......
[4 replies] Last: Merge Sorting algorithm and Quick sort algorithm are known as divide a... (by GrShultz)
how to look for the index of a vector in an array
 
int D ={ {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}, {0, 0, 0},...
[4 replies] Last: You could use a bool variable as a flag. Set it to true at the sta... (by Chervil)
Minimum processing cost!!
 
Hello everyone!! I need some help if possible with my problem given to me from my teacher.I will describe it here: Assume that processing a list of items costs...
[4 replies] Last: I used f variable to be assigned to the list2 array,so it can increm... (by cire)
by Gyiove
Hyperbolic Secant in c++
 
Hello everyone! Does anyone have a hyperbolic secant function? I found this: http://mathworld.wolfram.com/HyperbolicSecant.html But i don't understand...
[5 replies] Last: Hill representing momentum of how number changes Even if sech(1) ~= 1... (by helios)
How do i get more dubs? (Blackjack code)
 
#include <iostream> #include <ctime> #include <cmath> #include <cstdlib> #include <stdio.h> #include <stdlib.h> #include <windows.h> #define _WIN32_WINNT...
[1 reply] : This is very hard to read. Please Remember to put code tags. I really ... (by Hirokachi)
loop help?
 
I cannot attach a screen shot but this code compiles. Ehh no it does not at all. It would be much easier if you actually provided a piece of code that compil...
[5 replies] Last: so could you. Are you going to continue to waste my time or are you g... (by MikeyBoy)
need help
 
i need help on a guy who is nice and friendly
[1 reply] : So what's the problem? Is the guy not compiling properly? (by Michael5)
Trying to read a specific line of text from a file
 
I've got a dump file from a mathematical problem that records all tried solutions to a specific formula. Since I will be starting and stopping my program multip...
[2 replies] Last: Here is a little example to read the last 26 chars from a file. #inc... (by Thomas1965)
January 2016 Pages: 1... 910111213... 18
  Archived months: [dec2015] [feb2016]

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