Beginners

by admin
Welcome -- read before posting!
 
Welcome to the beginner's forum in C++.com! In this forum, users can to talk about any topic related to C++ for non-expert audiences. Feel free to participate...
[2 replies] Last: How To Answer Questions in a Helpful Way Be gentle. Problem-relat... (by admin)
Console Closing Down (1,2,3,4,5,6,7)
 
Hi, i am new to C++ and have just written my "Hello World" program. It worked all right but the console/cmd closes down instantly. If you tell me why it is clos...
[120 replies] Last: It displayed "Hello world" after you pressed Enter. int c is a ... (by Duthomhas)
by zzzhhh
Where is const mandated in the Standard when binding an lvalue reference to an rvalue?
 
I'm reading the part of the Standard about initializing an lvalue reference from an rvalue (https://eel.is/c++draft/dcl.init.ref#5.3 ). I know a reference to co...
[1 reply] : I don't think I've ever actually read the standard in over 30 years of... (by seeplus)
by zzzhhh
Should the subscript "opt" be dropped in the definition of "array of N T" in the standard?
 
This is the definitive syntax of "array of N T" in C++ Standard https://eel.is/c++draft/dcl.array#1 : D1 [ constant-expression_opt ] ... I think the subs...
[2 replies] Last: Thank you! (by zzzhhh)
stack and heap
 
Hi, I have some programming concepts question: Why is stack (in context of stack and heap) considered LIFO (last in first out)? The last time i checke...
[8 replies] Last: I guess that you are talking about "program stack" Yes. But not only... (by kigar64551)
by zzzhhh
Which item stipulates that A() is a prvalue?
 
class A { ... }; A(); This webpage lists all possible forms of prvalue expressions: https://en.cppreference.com/w/cpp/language/value_cat...
[2 replies] Last: I believe that A() is a function-style cast expression and is covered ... (by mbozzi)
How to compare int class template value?
 
I'm aware I should use std::string but this is question is about using template specialization a specific way. I'm learning about template specialization and ...
[2 replies] Last: 2. That's a good point. Only up to MAX_CSTR_SIZE-1 bytes will be copie... (by ElusiveTau)
Template errors creating a map<int,std::thread> using map::emplace
 
I created a class to try out std::lock_guard. The first function, UnsafeExample compiles and runs fine. The second example, SafeExample does not compile a...
[2 replies] Last: Thanks Peter. That was it. 1. std::ref(coutMutex) was necessary, for ... (by ElusiveTau)
How to initialize base class member with subclass member?
 
I'm working with code where CustomThreadApi is not modifiable. CustomThreadApi has a ctor that takes a const char* . I would like to assign MyThreadClass.Nam...
[2 replies] Last: baseClassBuff is unnecessary. I can just reuse MyThreadClass.Name .... (by ElusiveTau)
Removing double quotes from Cstring
 
Hi, sorry its late... I am trying to do a few things with strings. - I need to remove double quotes from a users input - Then the string needs to be divide i...
[8 replies] Last: You only get double quotes if some component of the filename path has ... (by Duthomhas)
Are these ternary operators the same?
 
Hello, What are the differences between these? #include <iostream> int main() { int a = 18, b = 44, total = 0, total2 = 0; total +=...
[8 replies] Last: I think some chips have a way to test a single bit but in general, I d... (by jonnin)
by Dazzer
How to start with audio plugin GUI design?
 
Hi folks, I'm interested in learning C++ for audio plugin design, but I'm a bit unusual in that i'm not really interested in the audio DSP part, i'm only rea...
[1 reply] : we used to call it RAD (rapid application development) and I am not su... (by jonnin)
How to get program to distribute input by alternating between two, multi-line string inputs
 
Hello I need to get this output: 1) type a: 1a type b: 1b 2) type a: 2a type b: 2b 3) type a: 3a type b: 3b 4) type a: 4a ty...
[5 replies] Last: You can do it with just 1 loop to read the data. Consider: #include... (by seeplus)
zero dynamic memory allocation
 
So today I was reviewing teacher code that lets student input the number of blocks of memory to allocate, but the student can input zero. It seems to allocate t...
[4 replies] Last: Well it was written by a teacher. I need say no more..... (by seeplus)
Why its showing wrong ?
 
Hi there, I am trying to run a code what school going student can do ! But not sure what kind of mistake I am doing. Take a look the program #include<s...
[6 replies] Last: Just because you can doesn't mean you should. :) do-while without... (by seeplus)
Lambda Expression: Specifying "this" in the capture clause
 
I'm reading an article on how to use lambda expressions and have some questions: 1. What is meant by "Only variables that are mentioned in the lambda body a...
[6 replies] Last: @Peter87, I am cognizant of the how and why of the differences in lamb... (by deleted account xyzzy)
Specifying a file address?
 
Hi, I am getting an error when trying to specify a file path for my program. It says "failed to open file for writing". I searched around google but couldn't f...
[8 replies] Last: seeplus already mentioned about the <format> library in C++20, a maj... (by deleted account xyzzy)
by zzzhhh
Why const literal class is not a constexpr even if initialized from a constexpr?
 
class test{ public: constexpr test(){} constexpr int operator+(const test& rhs) const { return 1+rhs.x ; } int x = 10 ; }; cons...
[4 replies] Last: Good point. I suppose you could remove x. I'm not sure what the point ... (by DizzyDon)
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is... (1,2)
 
Hi, I am getting an error when I run my program. the error is... Unhandled Exception: System.AccessViolationException: Attempted to read or write prote...
[26 replies] Last: you can choose to hunt down some of the offending memory hogs and mov... (by seeplus)
Bit set function not working correctly?
 
Good day, I don't know how to ask this as I don't totally understand things but I'm having an issue. My program reads tiles and tile sets from a game. The...
[12 replies] Last: [quote=Cyclone]My code is messy and had left over variables from testi... (by TheIdeasMan)
  Archived months: [nov2024]