Beginners - September 2022 (Page 2)

Unexpected behavior 2!
 
Consider the code below: int total; std::cin >> total; int ary ; for(int i=0;i<total;i++) ary = i; for(int i=0;i<total;i++) std::cout...
[9 replies] Last: It's not as straightforward as it looks because it interferes with the... (by Peter87)
A linux for programming
 
I never used a linux OS, I am open to the idea of using it lately, what is the best linux for programming you advice? thanks
[18 replies] Last: Got it, thank you everyone) always honored. (by ninja01)
Work around for limitation of template virtual member functions?
 
Hi I have a Message class which other classes inherit from. The inherited classes will need to have a serialisation member function. I would like to make these...
[1 reply] : You could use some special-case code for each class, or exploit that T... (by mbozzi)
checking if the inputs are valid Palindrome
 
How can I make this program work to determine whether these 5 palindromes are valid or not? #include <iostream> #include <string> struct Result { int...
[6 replies] Last: thank you guys :) (by cplus2303)
building a multilayer perceptron
 
Hello, I want to implement a simple multilayer perceptron for digit recognition. I have started to read the c++ primer 5th edition book 2 days ago so I am no...
[9 replies] Last: @dvdlly, I am well aware that the code you provided is a header file, ... (by lastchance)
Unexpected behavior 3!
 
In the following code it is clear that ptr holds an address int nbr = 3; int *ptr = &nbr; std::cout << &nbr << std::endl; std::cout << ptr << std::endl...
[6 replies] Last: [quote=jonnin]some embedded systems expect you do to this (but their l... (by Peter87)
Binary search of a dynamic array of strings
 
Hey yall, so for school I have to make a recursive word ladder program, and I wanna put a binary search in it. I have a function that checks the inputted word i...
[17 replies] Last: OK. We have a winner! Obviously that's what I meant to say when I said... (by seeplus)
Is this an address?
 
int main() { int *ptr; std::cout << ptr << std::endl; return 0; } I know that uninitialized pointers should be avoided because the...
[3 replies] Last: Technically it's undefined behaviour. [quote=jonnin]now your program ... (by Peter87)
Pointer Practice
 
Hi, I am currently experimenting with pointers and classes. Everytime my pointer reach 80% of its size, I attempt to create a expand it's capacity by 100% by u...
[3 replies] Last: There's also an error on L72... Also the code can be somewhat simplif... (by seeplus)
by Geckoo
input parser
 
// here we can write directly our algorithm so as to generate a track inline char algorithm(int t) { return (~t >> 2) * ((127 & t * (7 & t >> 10)) < (245 &...
[11 replies] Last: For a simplified getNum(), consider: template <typename T> requires... (by seeplus)
print every second leaf node from right to left
 
let me say that I have tree and the tree has these leaf nodes from right to left: [ 9, 4, 6,16 ,8,19, 10,8 ], I should write function to print every second lea...
[2 replies] Last: Maybe something like (not tried): void writeEveryOtherLeafNode(Node... (by seeplus)
char* mystery output
 
for first b->readData() i get Enter Student name: Enter Student surname: Enter Student ID: but for second on i get Enter Student name: Enter Student surn...
[10 replies] Last: where Enter Student name: Enter Student surname: are together when us... (by seeplus)
Valid Access
 
This is the code we were given and the question is , Is line 18 (return x;) a valid access and justify your answer. My question is. What is Valid / Invalid acce...
[12 replies] Last: @anonomyss: Can you now answer the questions below? class A { int... (by keskiverto)
They overloaded a struct constructor?
 
I was checking out the "Flare Game Engine" source code for fun, and I came across this: [line 6] class Color { public: Uint8 r, g, b, a; Color...
[4 replies] Last: Thank you guys, I've already got a couple of situations that I could u... (by newbieg)
#if 1 statements #else other statements
 
In the following preprocessor code what is the use of statements and other statements? When will the other statements be used? Please explain what is the use o...
[7 replies] Last: Thank you all for the excellent information. Best regards, (by AlexCantor)
Questions about pointer address
 
Consider the code below: int nbr = 3, *ptr = &nbr; std::cout << ptr << std::endl; int *ptr2 = nullptr; std::cout << ptr2 << std::endl; My output is: 0xb...
[9 replies] Last: std::format can print out pointer addresses, it has a format presentat... (by deleted account xyzzy)
Weird output!
 
Consider the code below: int nbr = 7; string str = "Hello world"; cout << str << ' : ' << nbr << endl; I putted the string literal " : " inside th...
[12 replies] Last: Thank you everyone) (by ninja01)
Help with code
 
I need to change the count() so that it counts down till 0 but it should still remain a recursive function and should not be a for loop. #include <iostrea...
[6 replies] Last: #include <iostream> void count(int counter) { if (counter >= 0) { ... (by seeplus)
printing a user input in Queues
 
How can we print user input variables including their ID, Name, and Pages of their document in Queue structure with an int main function? #include<iostream> ...
[2 replies] Last: thank you so much man :) (by cplus2303)
Override Class member array variable values
 
When I have an array as a class member variable and I want to override the default values by calling a separate constructor. Is what I am doing the optimal w...
[10 replies] Last: Yes, it's global. But that's fine as it's a global constant. constexp... (by seeplus)
September 2022 Pages: 1234
  Archived months: [aug2022] [oct2022]

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