Answer the question
In order to leave comments, you need to log in
How to access a class parameter?
3 am, I can't take it anymore, I'm tired.
We need to make a program, and so it turns out that we need it on the pluses.
class A(object):
def __init__(self, b):
self.b = b
a = A(1)
print(ab)
This is how easy it is for me to access class parameters.
I need the same, only on the pluses.
===========================
Header:
#pragma once
class Window
{
public:
Window(char* fileName);
voidMaximizeWindow();
};
============================
The class itself:
#include "Window.h"
#include
Window::Window(char* fileName) {
fileName = fileName;
}
void Window::MaximizeWindow() {
Get the value of the Window class parameter here
}
============================
Answer the question
In order to leave comments, you need to log in
You can access a class field like this:
#pragma once
#include <string>
class Window
{
public:
Window(const std::string& fileName);
void MaximizeWindow();
private:
std::string _fileName;
};
#include "Window.h"
Window::Window(const std::string& fileName)
: _fileName(fileName) {
}
void Window::MaximizeWindow() {
// Здесь можно обратиться к полю _fileName
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question