#include<iostream>
#include<string>
using namespace std;
class Human
{
public:
string name;
int age;
Type: Posts; User: solidusMGS
#include<iostream>
#include<string>
using namespace std;
class Human
{
public:
string name;
int age;
That's what I thought, but I read in the text, it said to leave the setters original and to just add the new setters. Maybe I'm just crazy and stupid.
See you down at Arizona Bay!
But I followed the book letter-by-letter!
Where did I go wrong with the first example? Member variables are age, etc, member functions are what?
Bae please!
Does code go something like this:
#include<iostream>
#include<string>
using namespace std;
class Dog{
But I have been doing cpp for two years! And all studies show all takes to become good at something takes 30 hours of time spent on it.
Plus, I am confused with the order and why it isn't...
But a lot of those books are not in C++ 20!
Ok, can you suggest a book?
It said to do it.
#include<string>#include<iostream>
using namespace std;
class Dog
{
int age, weight;
string color;
I originally could compile it successfully, only when I added more did things go wrong...
Now you are just being smug and not helpful. I could use a new book, but still. It won't help if I didn't get something as simple as encapsulation and how to do it right.
But the book showed the code in that form. The member variables go into the main block or the class block?
main.cpp: In member function ‘void Dog::setAge(int)’:
main.cpp:12:24: error: ‘age’ was not declared in this scope
12 | void setAge(int yrs) {age = yrs;}
| ^~~...
#include<string>#include<iostream>
using namespace std;
class Dog
{
void setValues( int, int, string);
public:
#include<fstream>#include <string>
#include <iostream>
using namespace std;
int main()
{
const int RANGE = 12;
string tab[ RANGE ];
int i = 0, j = 0;
I code the way it is suppose to, but cgywin closes the window after compiling, and I don't understand why? Does anyone know how to troubleshoot cgywin for fstream?
It's mostly a hit or a miss...
Not saying I don't believe you!
Just kinda curious how you would fix it....
But I copied the code word-for-word!
#include<string>#include<iostream>
using namespace std;
void computeFeatures(string);
int main()
{
string text = "Cpp is fun";
Trying to use an inline function to do a factorial, yet won't compile:
#include<iostream>using namespace std;
inline int factorial(int n);
int computeFactorials(int, int);
Thank you, daddy. I love you.
Sorry, I meant to say with the = sign nothing compiles and get an error.
I tried that and it did not compile. When I do compile I get rubbish memory instead of the value in the code.
The value is correct...almost. I don't get the 25 value the boook gets:
#include<iostream>
using namespace std;
int main()
{
int *num_ptr{ nullptr };