Dima
Roxifλsz 🇱🇹
That indeed is a good response to the above message
Roxifλsz 🇱🇹
Aaaand it got deleted
V01D
Mar!o
Lol
I_Interface
Roxifλsz 🇱🇹
Noob.
That's a very cool opinion, but I really don't remember asking
I_Interface
Daniele
Guys I have an issue: I'm trying to declare a object of class Selector inside another class Game. The compler says that "Selector does not name a type"
Daniele
Daniele
this is the error
Daniele
Daniele
this is class Game where it's included
Daniele
of course I included the correct file (Selector.hpp)
Kenny
share code bro
Daniele
not much to share tbh
Daniele
#pragma once
#include "Globals.hpp"
#include "Enums.hpp"
#include "Texture.hpp"
#include "Selector.hpp"
//This class controls the various menus, uses an object from the Selector class to make selections
class Game {
public:
Game();
//Get game info
enum ASTRD_MENU getCurrentMenu();
enum GAME_TYPE getGameType();
enum DIFFICULTY getDiff();
enum ASTEROID_SPEED getAstSpeed();
//Get selector info
enum BUTTON getSelectorItem();
Texture getSelectorTexture();
float getSelectorX();
float getSelectorY();
//Set game info
void setCurrentMenu(enum ASTRD_MENU newMenu);
void setGameType(enum GAME_TYPE newGame);
void setDiff(enum DIFFICULTY newDiff);
void setAstSpeed(enum ASTEROID_SPEED newAstSpeed);
//Set selector info
void setSelectorItem(enum BUTTON newItem);
void setSelectorX(float newX);
void setSelectorY(float newY);
private:
enum ASTRD_MENU mMenu;
enum GAME_TYPE mGame;
enum DIFFICULTY mDiff;
enum ASTEROID_SPEED mAstSpeed;
Selector mSelector;
};
Daniele
Selector mSelector is the line where the error occurs
Tute
I've made a Serial Port to TCP/IP Socket bridge, it's pretty simple, but it could be helpful...
https://gitlab.com/tute-avalos/serial-tcp
᳅𝙈𝙑𝙃𝙈𝙊𝘿
Hi
᳅𝙈𝙑𝙃𝙈𝙊𝘿
What is the best way to start learning C++😕
Anonymous
Stop asking how and do something
Anonymous
Pavel
Is it only me who didn't get the question at all?
V01D
Variables, because I don't know OOP..
Anonymous
Anonymous
Anonymous
I mean to say
Like
If you want to calculate avg of number .....
And you use a function for it
Than
The number of arguments taken by the function would any number of arguments right
Means like..
avg(3,4,5,6)
avg(8,6,7,6,6,7,)
Like this ....
Anonymous
And how OOP can help you here?
Pavel
Anonymous
Anonymous
Pavel
also initializer lists can be helpful here
Anonymous
Alex
Alex
or two iterators
Alex
variadic template is bad idea cause for average value all vars should have common type
Alex
also is hard to maintain
Anonymous
Args&& ...arg have common type?
Alex
no
Anonymous
Pavel
Anonymous
Anonymous
he doesn't show up for more details btw😆
Alex
stl c++ approach for sum:
https://en.cppreference.com/w/cpp/algorithm/accumulate
no variadic template
Anonymous
/getcbook
Anonymous
template <typename... Args>
requires (std::convertable_to<Args, int64_t> && ...)
int64_t avg(Args... args) {
std::array nums = {args...};
// Compute average
}
Anonymous
Alex
Anonymous
Alex
yes, but I can`t get it with your function prototype
Alex
probable I will template error mess
Alex
also you return int64_t, what if I pass double?
Alex
this code is not correct
Anonymous
Alex
so this is hard
Alex
you made mistake
Anonymous
so this is hard
He needs variable arguments length in the function
Anonymous
Anonymous
Initial question used only integers
Alex
iterators allow you any container and any type
Anonymous
Again
https://t.me/programminginc/319791
Alex
vector allows you any type, any you can use init list
Alex
I consider variadic template as the worst approach among three
Anonymous
Alex
Anonymous
Anonymous
template<class T>
T sum(T t){
return t;
}
template<class T, class ... Args>
T sum(T t,Args ... args){
return t+sum(args...);
}