Pavel
If I want to have a templated class and to create a typedef with exact parameter to use in the real cases of my application, what prefix or suffix for the templated class would you suggest to use?
example
template<typename TypeId>
class EntityManagerT { ... };
template<typename TypeId>
class EntityManagerViewT {
using EntityManager = EntityManagerT<TypeId>;
...
};
using EntityManager = EntityManagerT<int>;
using EntityManagerView = EntityManagerViewT<int>;
Here I use T suffix, but I guess there should be a name convention or something for such a case. I want the final typedef to be the name that is being used in the app, so I want to avoid any prefixes or suffixes there.
Anonymous
Impl?
Pavel
Like this?
template<typename TypeId>
class EntityManagerImpl { ... };
using EntityManager = EntityManagerImpl<int>;
Feels inverted, but better than T at least :)
klimi
no, because this is c/c++ group, if you want to ask offtopic questions, go to the offtopic group. thank you
Anonymous
/warn off
Anonymous
Top
ㅤ
/get cppbookguide
Half Blood Prince
/get best-book
Half Blood Prince
#cpp
Yohana
Thanks
𝚕𝚊𝚒𝚗𝚋𝚘𝚝.𝚜𝚌𝚖 🇺🇬
#rose_as_my_girlfriend
Shahar
Little question about this code:
char shellcode[] = "\xbb\x00\x00\x00\x00"
"\xb8\x01\x00\x00\x00"
"\xcd\x80";
int main(int argc, int **argv) {
void (*ptr)();
ptr = (void (*)()) shellcode;
(*ptr)();
return 0;
}
Why ptr is dereferenced at the third line of main in order to be called?
As I understand, ptr itself is equal to a pointer pointing to shellcode variable casted to function pointer.
So what's the effect of dereferencing it? Shouldn't it be called by ptr() and that's it?
Ammar
Shahar
Anonymous
Mercedes Antiq
Hi
Ehsan
Anonymous
Is the cpp book by Bjarne Stroustrup recommend or not? I don't see it on the stack overflow recommendations page but it was on official isocpp site. Oh it's there, thanks.
Ehsan
professor
me again. I Have a workflow where I Have 4 models vendor, products, vulnerabilities , and exploits), and each model can receive multiples sources of data such as google, yandex, yahoo, etc as an example . I think based on this I need to create four pipelines , and multiples senders, what do you think on it?
Anonymous
?
Anonymous
Does derived class inherit the constructors of base class in single inheritance? If it does why can't I access the constructors of base class through derived class?
Anonymous
Anonymous
If you want to inherit constructors, write in the derived class:
using base::base;
Anonymous
Where base is a name of a base class
MAC
Anonymous
Nameful
Mercedes Antiq
read the rules
cout << "It seems that there are many actions not allowed." << "\n";
Mercedes Antiq
Hi from Panamá. My english is not ok
Anonymous
Hello, good morning
Anonymous
if I were to print to screen in C, using just macro and not having more than 32 characters... how do I proceed
Anonymous
Anonymous
Ammar
assert()
How come assert() related to printing function?
Anonymous
true... perhaps an example would do
Ammar
Anonymous
well, macro functions can do... my problem is having the limits of 32 characters
Ammar
Anonymous
Ammar
Well yeah, assert(0) would print fail message and abort your program.
Ammar
But what is it supposed to do?
Anonymous
Write a program that can print "Hello, World" followed by a new line.
You are not allowed to use more than one line of code
You are not allowed to use more than 32 characters in the file 101-preprocessor_abuse.c, including the documentation of your functions and the preprocessor directives
You are not allowed to include other c files
You are not allowed to include other header files
Remember: your program should pass all Betty checks for style and documentation
You don’t have to use the -pedantic, -Wall, -Werror, -Wextra gcc flags
This program should be written in C and will be compiled with gcc
Ammar
main(){printf("a");} seems to be the solution.
Ammar
main(){printf("Hello World\n");} it is exactly 32 characters.
Anonymous
Ammar
So that's fine.
Shadow
Want data-structures- notes anyone having it?
Anonymous
Ammar
Though, it is bad. It may cause segfault if 64-bit pointer gets trimmed and lost its high part to 32-bit due to integer type juggling.
Anonymous
Anonymous
the compiler will print this, so idk if it counts
Abid
#include <stdio.h>
int main(){
printf("Hello world \n");
return 0;
}
Anonymous
Anonymous
101-preprocessor_abuse.c:1:8: warning: incompatible implicit declaration of built-in function ‘printf’
101-preprocessor_abuse.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include <stdio.h>
1 | main(){printf("Hello, World\n");}
Anonymous
thanks everyone...
Anonymous
I think it has to be a macro function but the limit of 32 characters is just my strain
#define print(x)#x (puts(x))
main(){print("Hello, world")}
GXUP320
Anonymous
thank you all🙏
Anonymous
Anonymous
Anonymous
Yes... very true....
The Shadow Monarch
/get cppbookguide
Nishant
Anyone wants to learn C/C++ from University of California Berkeley?
Anonymous
Nishant
No
Nishant
Directly you can enroll from university website
Anonymous
Anonymous
Or don't write at all
klimi
Abid
auto x = "This is a c-string";
decltype(x) y;
Error:
"x dose not name type"
"x was not declared in this scope"
What is the solution?
Anonymous
Abid
#include <iostrem>
#include <typeinfo>
#include <string>
using namespace std;
int main() {
int i=47;
const char * cstr = "this is the c-strin";
const string sclass =string("this is a string class ");
auto x = "this a c-string";
decltype(x) y;
cout <<"Type of i is " <<typeid(i).name()<<endl;
cout <<"Type of cstr is " <<typeid(cstr).name()<<endl;
cout <<"Type of sclass is " <<typeid(sclass).name()<<endl;
cout <<"Type of x is " <<typeid(x).name()<<endl;
cout <<"Type of y is " <<typeid(y).name()<<endl;
return 0;
}
@unterumarmung
Pavel
Abid