how to use struct in a class

lifeform.h class lifeform { public: struct item; void buyItem(item &a); //code.. }; lifeform.cpp struct lifeform::item { std::string type,name; bool own; int value,feature; item(std::string _type,std::string _name,int _valu...
more »

2017-04-19 16:04 (1) Answers

CLion 2017.1 CMake compile error on mac OS10.12

I installed the CLion for mac. But when I create a "Hello, world" project, I got some problems. It seems like CMake failed to set system information or what. This is my CMakeList.txt generated by CLion default: cmake_minimum_required(VERSION 3.7)...
more »

2017-04-19 10:04 (1) Answers

PGI compiler: compile-time error on macOSX

my macOS is 10.12.4 and I have already installed the PGI on my macbook(just install by a setup program downloaded from PGI official website, activate its own console and no other operation, in this console, there have commands like "pgcc pgc++ and so...
more »

2017-04-19 09:04 (0) Answers

c++ read from a file and output sorted content

I am learning to code and found interesting task, but i do not know where to start in solving it. So i have a file with some titles and comments which need to be placed under the right title. So the first line of the input contains a number N which d...
more »

2017-04-18 16:04 (1) Answers

learning c++: error: use of deleted function

I'm doing some exercises from the book "think like a programmer" and everything has been great so far. I started the classes chapter and here I seem to be stuck as I can't wrap my head around the error I'm getting compiling the code. Here is the co...
more »

2017-04-17 20:04 (3) Answers

SDL2 Thread not working inside class

I am trying to create a input handler using multi threading with the SDL2 Library; however, when I try to put a thread in a class it won't compile and gives me this error... error: cannot convert 'inputHandlerClass::getInput' from type 'int (inputHa...
more »

2017-04-17 19:04 (1) Answers

call a function from an array of vectors

In following code, i get an error on line 33. Why? What is the correct syntax? Surely I made some stupid mistake ... unfortunately I'm trying to better understand the vectors. #include <iostream> #include <vector> class firstClass { ...
more »

2017-04-17 17:04 (1) Answers

c++ validation login code

i am trying to make a simple validation user name and password for my program. i am not sure whats wrong with my code, but i think i have some logic error here is my piece of code string usernameinput,passinput; string username[]={"mmm","...
more »

2017-04-16 20:04 (2) Answers

std::sort by unary mapping

The C++ standard library offers to pass a Comparator to std::sort. However, I have many cases in my code where I want to sort a list of T objects by a function f. A comparator like this would be a valid option: bool compare(const T& a, const T&a...
more »

2017-04-16 15:04 (2) Answers