Questions tagged as 'c++'

2
answers

Independent member function in C ++

I'm learning OOP with C ++. I made a program here to train the question of object arrays. My question eh: The program is working, but was it efficient for me to have put the show_dados2 function as independent? I could not develop the logic to p...
asked by 27.08.2017 / 22:15
1
answer

Unpacking dynamic stack

I have a dynamic stack algorithm. Only if I insert 10 elements into the stack and it is unstackable without removing the first element it from the segmentation fault. And if I remove the first element from the top left over 9 8 7 6 5 4 3 2 1 and...
asked by 13.01.2018 / 16:45
1
answer

Call any function of another class of the same type

I need to pass as parameter to a member function another member function (but from another class). I can do this for functions of the same class, but of another I still can not #include <iostream> using namespace std; void MyP(int a)...
asked by 16.09.2017 / 14:42
2
answers

Remove first element from a simple chained list

I would like to do a function to remove the first element from a linked list, the way I did it it is only removing the first node and removing the second element. struct lista { int info; struct lista* prox; }; typedef struct lista Lista;...
asked by 12.10.2017 / 09:13
2
answers

Operations with arrays in C ++

To sum the items of an array (primary diagonal and secondary diagonal) I was able to write the following code. Can someone help me make the code leaner? so I compare the codes ... C ++: And I would like to know if there is any function for this...
asked by 07.08.2017 / 00:49
2
answers

C ++ method assignment

#include <iostream> using namespace std; class Aluno{ public: string nome; int idade; float n1; float n2; float media(float n1, float n2); }; float Aluno::media(float n1, float n2){ return (n1+n2)/2; } int ma...
asked by 31.05.2017 / 21:48
1
answer

How to check if the value of a key exists on a map in c ++

I'm doing a TAD of graphs and I use a map structure to map the ID of a vertex to its index in the adjacency array and to do that I need to first check if given the vertex id it's already added to the graph, so how can I check if there is a mappe...
asked by 02.07.2017 / 23:59
1
answer

Would you like to add a parameter in: system ("color", var) in C language?

I'm creating a simple program to change the color of the system. Only, I want to give the user the option to write the color he wants. Ex: Has the table 1: Blue 2: Green F: Red C: Yellow Being F background color and 1 font color. Then looking...
asked by 02.04.2017 / 04:27
1
answer

Operator overload ==

bool Stock::operator== (const Stock& stk){ if ( this->get_resource() == (stk.get_resource()) ) return true; else return false; } I created this method to overload the operations of a class, however, when I instantiate pointers...
asked by 20.02.2017 / 01:36
1
answer

How to sum the values in a loop?

I want to add and display the total value of the query. In the case of 3 patients the sum would be 1350. But something is going wrong. case 2 : printf ("Particular:\n"); printf("O valor da consulta e de R$ 450,00: \n"); for(i=0;i<3;i++) {...
asked by 26.05.2017 / 16:34