Posts by xninja • 357 points
9 posts
-
0
votes1
answer174
viewsQ: How to fix the error: "declaration of template Parameter’T' Shadows template Parameter" in C++?
I’m trying to do a Polygraph program, but I’m having a problem... My code and this: main.cpp: #include "point_2d.h" #include <iostream> int main() { cge::point_2d p(5, 5); p.x = 6; std::cout…
-
0
votes2
answers53
viewsQ: Why am I having trouble with C-scanf?
Hi, I’m trying to do a very basic cmd, but I’m having problems... My code: #include <stdio.h> int main() { char arg[300]; scanf("print '%s'", arg); printf("%s", arg); fgetc(stdin);…
-
1
votes2
answers2327
viewsA: Object vector in C++
1. Use the library C++ offers you. Your code looks like C, not C++. You can use the STL to make your code simpler and clear. 2. "using namespace Std" is a bad practice. When you write using…
-
2
votes2
answers90
viewsQ: Why can normal functions not have "auto" arguments if "lambda Expressions" can in C++?
I realized that the "lambda Expressions" accept arguments of the type auto. For example: auto add = [](const auto& x, const auto& y) { return x + y; } So I tried normal functions, but it…
-
0
votes1
answer47
viewsQ: How do I place strings like 'char32_t' and 'char16_t' on the console in C++?
New C++17 added characters char32_t and char16_t, added also 'u16string' and 'u32string', but did not create any way to put them on the console screen. For example: int main() { std::u16string u16s{…
-
4
votes1
answer129
viewsQ: When is the destroyer of an object called in C++?
Let’s assume I have a function: std::string empty_string() { std::string x{ "" }; return x; } As normal as it sounds, it gets a little fuzzy when we think: When the destroyer of the object x is…
-
6
votes1
answer183
viewsQ: Why is there no "Logical XOR" in C++?
I was thinking and I came up with this question: Why is there "Bitwise OR", "Bitwise AND" and "Bitwise XOR", if in Boolean logic there is only "Logical OR" and "Logical AND". There should be the…
-
5
votes2
answers140
viewsQ: How to verify if a type is numerical in C++?
Let’s assume I have a function: template<class T> T soma(const T& x, const T& y) { static_assert(/*O tipo é for numérico?*/, "Tipo de argumento inválido, O argumento precisa ser…
-
6
votes2
answers929
viewsQ: What is the difference between expressions : "int a" and "const int& a" as C++ function arguments?
Let’s assume I have two functions: int soma_a(int a, int b){ return a + b; } and int soma_b(const int& a, const int& b){ return a + b; } What would be the difference between soma_a and…