Video není dostupné.
Omlouváme se.
C++ Typedef and type aliases explained 🙋♂️
Vložit
- čas přidán 18. 05. 2024
- #typedef #using
// Typedefs and type aliases
// typedef = reserved keyword used to create an additional name
// (alias) for another data type.
// New identifier for an existing type
// Helps with readability and reduces typos
// Use when there is a clear benefit
// Replaced with 'using' (work better w/ templates)
#include
//typedef std::string text_t;
//typedef int number_t;
using text_t = std::string;
using number_t = int;
int main(){
text_t firstName = "Bro";
number_t age = 21;
std::cout
I have an error that says conversation from 'int' to non scalar type 'number_t' {aka 'std::__cxx11::basic_string'}
I'm using VS code BTW
I always used to use typedef for renaming structures when i was learning DSA basics in Clanguage, it just made the declarations of node pointers so easy.Great video mate🥰🥰
Man why you have so few views? you deserve more views
Right? I'm guessing because it's a brand new series. He also has this video unlisted though so that's def tanking his viewership.
@@areotaco5044 By any chance in the 5 months are you at least ok in c++?
@@clydebaldassare2387 how ab you my friend? are you at least “Good” at c++ in 4 months?
Because most of the viewers never leave likes and comments and even subscribe.
Older Bro: "Are you using typedef?" ☹
Younger Bro: "No, bro. I am using using." 🙂
I'll use both versions of syntax. If I want to to call double float_t, I'll do it these two ways.
// First way
typedef double float_t;
// Second way
using float_t = double;
thank youu
Do C++ they said, it's easy as python they said, no confusion whatsoever they said.
I copied your code and it didn't work. I got several error messages, some saying 'expected nested-name-specifier before text_t and number_t'. Also saying its not declared. Wtf.
Bro this happens when I try to use using.
using.cpp:8:15: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using xt= std::string;
^
1 warning generated.
Any fixes? Tried many online, nothing works.
It says it was posted 2 days ago but has comments from a year ago?
I tried "using op_t = std::cout;" but it did not work for some reason,
can someone say why
Hey bro what's your extensions and terminal? I want to use. And please let me know how to set up
just create a new document and name in file.cpp
typedef int cheese_t;
using cheese_t = int;
typedef double decimal_num;
using decimal_num = double;
Is it complete course or just for beginners?
Just for beginners, I saw intermediate and expert tutorials online. TT
why cant we use typedef std::cout out_t
//double num = 3.5;
//typedef double decimal_t;
using decimal_t = double;
decimal_t num = 3.5;
std::cout
whatever anything before or after
First way: typedef std::string text_t ; Second way: using numbers_t = int;
using state_t = bool;
int main() {
state_t switch = true;
return 0;
}
I copy the code but I get not declared in this scope error and expected nested name specifer error
i also have the same error with you
what code did you copy? Also, don't copy code, type it out
typedef std::string stringA;
typedef int intergerA;
using stringB = std::string;
usinng integerB = int;
#include
typedef double float_t;
int main(){
float_t height = 1.89;
std::cout
using text_t = std::string;
int main() {
text_t sprinkles = "Pringles";
std::cout
wanted to see if it could work with name spaces and it worked:
#include
using number_t = int;
namespace first{ //Number 1
number_t x = 1;
}
namespace second{ //Number 2
number_t x = 2;
}
int main() {
number_t x = 0; //Number 0
std::cout
#include
using number = double;
int main()
{
number amogus = random();
std::cout
using desimal_t = double;
int main() {
desimal_t verdi = 3.5;
std::cout
dont forget to add #include
using Num = std::int;
Num = 4;
std::cout
#include
#include
typedef std::string message;
int main() {
message name = "Bro";
std::cout
it's more easy than python🤣🤣
yea its only the include io stream and return 0 that makes people go crazy lol
@@lolman6976wait until bro discovers pointers
using doub_t = double;
using float_t = double ;
typedef std::cout Print
typedef int integer;
using HH = bool;
typedef double float_t ;
typedef bool tf_t
using hi = bool;
Typedef std::string name_t;
Using name_t = std::string;
Int main(){
name_t firstname= "bro";
cout
typedef float decimal_t;
typedef double double_d;
using double_d = double;
double_d gravity = 9.8;
std::cout
#include
typedef int number_t ;
typedef std::string text_t;
int main() {
number_t age = 5;
text_t LastName = "Among";
std::cout
using str = std::string ;
typedef std::string text_t;
using liczba_t = int
typedef struct {
int score1;
int score2;
} grade;
int main() {
grade student1, student2;
typedef std::string ni;
ni tx="heyy";
using print = std::cout
typedef std::cout print;
#include
using std::cout;
using std::endl;
typedef std::string mes_t;
typedef float fl_t;
int main(){
mes_t name = "James";
fl_t bodyTemp = 36.5;
cout
typedef int num_t;
typedef double decimal_t;
using string_t = std::string;
using letter_t = char;
int main()
{
num_t catLives = 9;
std::cout
typedef std::string lol_t;
typedef std::endl endl;
typedef std::cout cout;
typedef std::cin cin;
typedef std::string word;
why not str
@@teagleh because you are free to do whatever you want🙃
#include
using quote_t = std::string;
int main() {
quote_t Quote = "Meron ka bang lemon? Gusto ko tequila!";
std::cout
#include
typedef std::string cnmeo_t;
typedef float oatdoheo_t;
int main ()
{
cnmeo_t ten="cn cak";
std::cout
using f_t = bool;
int main(){
f_t q; = true;
std::cout