Category : class

Last time I asked this question apparently I didn’t include enough info. I will include enough info this time and if I need to add more please just tell me, don’t just down vote it. Anyways, I have a program designed to simulate a ball bouncing in C++ and save the position, and velocity of ..

Read more

I’m making a program to generate training data for a project I’m doing by running multiple simulations at once in C++, I have a class, "Ball", and I have an update function to simulate it bouncing. The variables at the start of the simulation are randomized. The code for the update function: void update() { ..

Read more

I’m a programming student but my professor refuses to explain anything, in this assignment she introduced classes and I’m struggling to understand the constructor concept/syntax. I have a "matching constructor" error on two lines of my code (I’ve marked them with comments, the problem lines of code are both in main.) The code is a ..

Read more

I’m fairly new to c++-templates, and at the point where I’m realizing that I’m probably doing template meta-programming. What I want is to achieve the following definition: #include <type_traits> // T must be default-constructible template<class T, std::enable_if<std::is_default_constructible<T>>> class PoolAllocator { public: PoolAllocator(unsigned int numItems); ~PoolAllocator(); T* Alloc(); void Free(T* item); private: struct mPoolItem { T ..

Read more

#include<iostream> using namespace std; class Employee{ public: Employee(char* name,int _year,float _salary) { emp_name=name; emp_join_year=_year; emp_salary=_salary; Printinfo(); } private: int WorkedYear(void) { //struct date currentdate; int YearDiff; //getdate(&currentdate); YearDiff=2020-emp_join_year; return YearDiff; } void Printinfo(void) { cout << "Name :" << emp_name << endl; cout << "Join Date :" << emp_join_year << endl; cout << "Salary :" ..

Read more

void point::setVectorPoint(double x, double y, double z, double w) { this->xd = x; this->yd = y; this->zd = z; this->wd = w; }; this is where im getting the exception. my point class looks like this: #pragma once #ifndef POINT_H #define POINT_H #include "../src/pch.h" class point { private: double vectorPoint[4] = {xd, yd, zd, wd}; ..

Read more