Beginners - April 2019 (Page 15)

by sturk
C++ Polymorphism
 
Why is the output 'B' instead of 'BD'. Do not get it.. Given the following code: class B { public: virtual void foo(); }; void B::foo() { cout <<...
[2 replies] Last: pB points to an object of type B so that is why pB->foo() will call B:... (by Peter87)
by arg57
Why use std::
 
Why do some people use std:: when you can use "using namespace std " ? ng Put the code you need help with here. ng
[2 replies] Last: the 10 cent summary of the article is that std:: is huge beyond contro... (by jonnin)
Making the player go back to the same question
 
Hello, im trying to learn how to programm and im trying to make a little test now as my first project. I want to make it so if you get the answer wrong it throw...
[1 reply] : #include <iostream> int main() { const int correct_answer = 4 ; ... (by JLBorges)
Storing vectors in vectors?
 
So I'm new to coding and I'm having difficulty with this homework. Basically the hw is an athletic department wants a program that calculates the area of basket...
[5 replies] Last: it does not work that way. push_back puts an entire item of the <type... (by jonnin)
allow the user to skip entering one of the values
 
can someone give me an example of a code that will still run if the user don't input a data? like for example if the user has to put 2 numbers, and the user ski...
[2 replies] Last: #include <iostream> int main() { int first = 10 ; // 10 is the d... (by JLBorges)
by kenken
Primality test
 
This function seems to work for small number but fails with large number. Can anyone help me understand the problem. Thanks. bool isPrime(int number) { for...
[6 replies] Last: Its part of the language and has been for some time (c-99 era? not sur... (by jonnin)
Python to CPP
 
I have a code snippet of tree in python but I can't change it to C++ so I need help here def max_profit(node): return max(-X, node.value + sum(map(m...
[7 replies] Last: thanks i got it! but the max_profit() function which @helios converte... (by closed account STD8C542)
Need an approach
 
You are given a rooted tree with N nodes (numbered 1 through N); node 1 is the root. For each valid i, the i-th node has a value vi and another parameter mi. ...
[8 replies] Last: It seem to question from an on going contest https://www.codechef.com/... (by gokuluffy)
by m2020
operator precedence and pointer to an array
 
Hello everyone I have very basic questions 1- why the output of following code is 4? (in many ways i end up with value of 5) int i = 5; in...
[5 replies] Last: Thank you dear duthomhas. (by m2020)
Return type of std::map::insert
 
At the time I try to understand the behavior of the std::map facilities. Especially I want to know of what type the map::insert return type is. I know that for ...
[3 replies] Last: If you don't care if the key already exist or just want to overwrite o... (by Peter87)
by sturk
C++ multiple inheritances
 
Why is the answer 1 and not 2 to the following codes below? Revising for a test. Thanks! Given the following code with multiple inheritances: class A { ...
[1 reply] : ab.A::print(3.14f); This line specifically states that the print ... (by Repeater)
struct in c program
 
Bellow code is c programing. struct NodeStruct { int Base; int Value; void (*pinMode) (struct NodeStruct *node, int pin,int mode) ; } ; ...
[2 replies] Last: Thanks Duthomhas (by kakaducsy)
Reading input from file into vector
 
Hello, I was reading in Bjarne Stroustrup's "Principle and Practice Using C++" when I encountered the following example, where we are reading from a file. ...
[5 replies] Last: Zeta z; … anytype z; // redefinition of z vs for (…) { ... (by Duthomhas)
Getline Repeats cout command twice, Help please!
 
I'm trying to make a program that's just an general assistant. It works great. Just one glitch. When i type in my login username. It repeats "write something:" ...
[2 replies] Last: Hello navilgameboy, PLEASE ALWAYS USE CODE TAGS (the <> formatting ... (by Handy Andy)
Inventory/List
 
I am wondering what would be the best way to create an inventory class or list, to store and possibly display the Items-Weapons-Potions that I have created. I a...
[1 reply] : I would be inclined to use either a std::set or a std::map. Use a std... (by Duthomhas)
Getline Repeats cout command twice, Help please!
 
I'm trying to make a program that's just an general assistant. It works great. Just one glitch. When i type in my login username. It repeats "write something:" ...
[4 replies] Last: Yay. (by Duthomhas)
interactive program, sumone plz solve it
 
Write an interactive program that asks the user for the population of a country,and replies with how many percent of the world population lives in this country....
[4 replies] Last: Try solving this in 3 steps. First write a program that prompts for t... (by dhayden)
"Segmentation fault (core dumped)" While Using Recursion
 
Please Note: This is a homework assignment, however , the due date has already passed and I'm just doing it for the learning aspect. If you've seen my previo...
[6 replies] Last: [quote=jonnin] Nevermind :) I havent worked in octal in a while, and m... (by PiggiesGoSqueal)
by AlanW1
Homework Help Please - C++
 
In the new intellectual TV show, the participant passing to the super final is offered the following game: the letter of the Latin alphabet li is written on eac...
[8 replies] Last: dhayden, I will try to do it yourself according to your recommendation... (by AlanW1)
April 2019 Pages: 1... 1314151617... 24
  Archived months: [mar2019] [may2019]

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