Questions tagged as 'c++'

3
answers

Problems with "or" in C ++

I need to make an algorithm that gets 3 different numbers, and if it receives repeated numbers, it informs an error message. My program is all working properly, but when I put the line to warn of the error I try to use Or and it does n...
asked by 06.03.2015 / 01:12
2
answers

#pragma once or #ifndef?

I know there are two ways to prevent a header file from being duplicated in C \ C ++: #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED class Foo { // código }; #endif E #pragma once class Foo { // código }; Being the first I...
asked by 17.03.2014 / 20:22
3
answers

What is operator overload?

In some programming languages such as C++ , it is possible to overload operators. What is it and what is it for?     
asked by 02.05.2015 / 19:47
4
answers

Is a compiler allowed to omit a reference member in a class?

Consider the following class: struct Type { int a, b, c; int& ref; Type(int m) : a(m), b(m), c(m), ref(a) { } Type(const Type& ot) : a(ot.a), b(ot.b), c(ot.c), ref(a) { } } obj; Here we have that sizeof(Type)...
asked by 20.02.2014 / 18:00
2
answers

char [] or * char malloc?

What difference in C between char text[10] or char *char = (char *)malloc(10*sizeof(char)); What advantage of using malloc on a pointer?     
asked by 21.07.2016 / 20:10
1
answer

Basic image editing using OpenCV

Hello, I'm learning how to use the features that OpenCV offers for image processing, and the following question came up: How do I edit only a predetermined area of an image? To make it easier for me to understand, I'm going to use the...
asked by 27.05.2014 / 23:43
2
answers

How do I access a specific RAM location by address?

I'm starting to study pointers in C / C ++ and it was something that drew my attention to the robustness and range of possibilities. However, I can only access memory locations by assigning my pointer an address of an already allocated variable,...
asked by 13.03.2014 / 18:07
2
answers

Can I use "cin" and "getline" in the same code?

I was fixing the whitespace problem with getline , but I got this problem where the question "Enter the employee name:" is skipped, how do I solve this? cout<<"\n\nDigite o nome da empresa: "; getline (cin,nom...
asked by 13.12.2015 / 15:51
2
answers

How to check for collision between particles?

I need to know how to make each circle collide with the other along with what I'm going to do to follow that direction after that collision. This is the program's main window class: class canvas : public QWidget { Q_OBJECT public: e...
asked by 26.04.2014 / 01:42
4
answers

Multiple return in C / C ++

Is it possible to return multiple values? For example: umafuncao() { int x = 1, y = 2; return x,y; } void main() { int a, b; a, b = umafuncao(); } I'm asking this question, because I built a code using this structure for a...
asked by 03.11.2015 / 14:25