Merazi
#duckit ever?
nice #duckit
Merazi
Get me for beginner
did you read the pinned message?
Roxifλsz 🇱🇹
That indeed is a good response to the above message
Roxifλsz 🇱🇹
Aaaand it got deleted
Mar!o
Lol
Roxifλsz 🇱🇹
Noob.
That's a very cool opinion, but I really don't remember asking
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
Tute
What is the best way to start learning C++😕
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
Anonymous
Pavel
Is it only me who didn't get the question at all?
V01D
Variables, because I don't know OOP..
Anonymous
you mean sizeof..(Args)?
Anonymous
Wat
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
Use variadic templates
I think it's a too complex solution for such a simple task
Pavel
also initializer lists can be helpful here
Anonymous
I think it's a too complex solution for such a simple task
It's the only valid one if he needs such function
Pavel
It's the only valid one if he needs such function
it's better than the initial two variants for sure
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
also is hard to maintain
Don't think so
Alex
Don't think so
comparing to simple vector variadic template is harder for sure
Anonymous
comparing to simple vector variadic template is harder for sure
Vector is not he needs for the function API
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
Alex
Vector is not he needs for the function API
iterators are also more simple, reliable and standard approach
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
I can pass different types
And it will not compile
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
Alex
so this is hard
Alex
you made mistake
Anonymous
so this is hard
He needs variable arguments length in the function
Anonymous
Alex
Why is this?
does not work for float
Anonymous
does not work for float
It should not work for float
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
I consider variadic template as the worst approach among three
It's the only correct one for the task
Pavel
I dunno what's hard in it
it already looks very complex, and you even didn't write the implementation
Alex
It's the only correct one for the task
why vector is not correct for avg?
Alex
Am I a joke to you?
vector has variable number of elements
Pavel
He needs variable arguments length in the function
we don't know the exact task, if he just needs to call it with known at compile time arguments, then the vector can be constructed from an initializer list
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...); }