Anonymous
Hey I'm new to here
Anonymous
Who knows to script an ally character for game can somebody help me?
Ammar
BD9a
how to access other class variable and read it's real-time value? variable value changed, but from other class Im still getting old value
Anonymous
@lightness_races_in_orbit
Aah alright. I just reply as I see the messages and go further down. So missed this.
Hamza
Anyone have source code for c++ project on hospital management if anyone have plzz share
Vlad
Probably you passed by value instead of a reference somewhere
Anonymous
how about - if constexpr (!std::is_same_v<First, Specific>) { bar(first); } else { void (Class::* fn)(Specific &&) const = &Class::bar; (this->*fn)(first); }
@hazer_hazer i tried writing this and found your mistake when it complained error: cannot bind rvalue reference of type ‘int&&’ to lvalue of type ‘int’ 11 | (this->*fn)(first); | ~~~~~~~~~~~^~~~~~~ template<class First, class ...Rest> void foo(First && first, Rest && ...other) const { bar(std::forward<First>(first)); bar(std::forward<Rest>(other)...); }
BD9a
Probably you passed by value instead of a reference somewhere
I have two classes, one Config and the other "XYZ" class. In XYZ class I have "Config config;" (in private). Then Im reading Config variable in XYZ class function (in loop, printing default value no matter what).
BD9a
As long as this "Config config;" isnt pointer it's runnable, If changed to pointer (changed . to -> ofc), app just crashed
BD9a
nah, I dont use const
Vlad
nah, I dont use const
Mind uploading code to pastebin
Vlad
So we won't be playing in a guessing game
BD9a
Yeah I know, but wait
BD9a
If I have declared Config object as pointer in XYZ public and then in main this: Conf config; Building building; building.config = &config; its working good. What is this?
Vlad
As long as building doesn't outlive config everything will be fine
BD9a
Is it necessary to have this to "read" real-time value of other class variable?
Vlad
Although you probably don't need a pointer
BD9a
I can link u this code (github), it's QT but my problem is c++ definetly
BD9a
https://github.com/BD9a/Minecraft-Clicker
Vlad
This one has a pointer member
BD9a
so what is the other way to "read other class variable value in real-time"
BD9a
yeah but u know xd the problem is value is "default"
Divya
Hi
Vlad
Computer does what it was told
BD9a
Lol you've got to allocate memory to a pointer
didnt know that, but u said it can be done in other way too, or sth like that xd
Anonymous
Hi
Hey
olli
Hi I've got template function that I directly call somewhere: template<class First, class ...Rest> void foo(First && first, Rest && ...other) const { bar(first); bar(other...); } It invokes these: template<class Arg> void bar(Arg && single) const { std::cout << single << ' '; } void bar(Specific && specific) const { std::cout << "SPECIFIC"; } template<class ...Args> void bar(Args && ...args) const { (bar(std::forward<Args>(args)), ...); } I thought that it gonna work because C++ chooses the most specific overloading, but, as I see, it doesn't if I call it from another templated function, so bar(Specific) never be called. I know, that if I directly call bar then bar(Specific) will be used if I pass Specific type, anyway, from in templated function it is not. Help please 😔
The error you see seems to be a GCC bug [1] as the standard explicitly allows this [2] An explicit specialization may be declared in any scope in which the corresponding primary template may be defined ([dcl.meaning], [class.mem], [temp.mem]). As a result this code compiles fine with MSVC and Clang [3] #include <iostream> struct Specific {}; struct Foo { template<class Arg> void bar(Arg && single) { std::cout << single << ' '; } template <> void bar(Specific && specific) { std::cout << " SPECIFIC "; } template<class ...Args> void bar(Args && ...args) { (bar(std::forward<Args>(args)), ...); } template<class First, class ...Rest> void foo(First && first, Rest && ...other) { bar(std::forward<First>(first)); bar(std::forward<Rest>(other)...); } }; int main() { Foo{}.foo(3, 2, 1, Specific{}); } [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282 [2] http://eel.is/c++draft/temp.expl.spec#3 [3] https://godbolt.org/z/49EbTKbvT
Anonymous
what is this code does?
olli
what is this code does?
Nothing special, it demonstrates the use of variadic templates in combination with explicit template specialization in class scopes.
Anonymous
programming sport league, ok
Mar!o
Shahar
pthread_join function changes the state of the pthread_t struct it gets as argument?
IAmMADMAX
Write a program to group the words according to their lengths from a given string S using a Hash Table of size k with separate chaining. Assume that only alphabets are present in the string S and maximum size of the string is 500. The words of the string are grouped using the following formula. Index_No = (length_of_word ∗ length_of_word)%k where % is the modulo operation and k is the size of hash table. If the string contains multiple occurrences of a word w, then it should not be added again in a group. Only the first occurrence of w is added to the group. Note: Hash table is implemented as an array in which each entry contains a head pointer to a linked list which contains the words of the same group. Words generating same Index_No belong to the same linked list (refer sample output for explanation). Duplicate words are not allowed in the list. Each node of the linked list is of the following type. struct node{ char *word; // word to be store struct node * next; //pointer to the next node }; Input Format: • First line of the input contains an integer ‘k’, the size of the hash table. • Second line of the input contains a string/sentence of words. Output Format: • Each line of the output should print the index number and words in it, separated by a colon(:). • The words inside a group are separated by minus sign(-). • If no words are present in the group then print ‘null’ in place of words. Sample Input 1: 3 Write a program to create a hash table. Sample Output 1: 0:create 1:Write-a-program-to-hash-table 2:null Sample Input 2: 5 This program is a program to create a hash table Sample Output 2: 0:table 1:This-a-create-hash 2:null 3:null 4:program-is-to
IAmMADMAX
Write a program to group the words according to their lengths from a given string S using a Hash Table of size k with separate chaining. Assume that only alphabets are present in the string S and maximum size of the string is 500. The words of the string are grouped using the following formula. Index_No = (length_of_word ∗ length_of_word)%k where % is the modulo operation and k is the size of hash table. If the string contains multiple occurrences of a word w, then it should not be added again in a group. Only the first occurrence of w is added to the group. Note: Hash table is implemented as an array in which each entry contains a head pointer to a linked list which contains the words of the same group. Words generating same Index_No belong to the same linked list (refer sample output for explanation). Duplicate words are not allowed in the list. Each node of the linked list is of the following type. struct node{ char *word; // word to be store struct node * next; //pointer to the next node }; Input Format: • First line of the input contains an integer ‘k’, the size of the hash table. • Second line of the input contains a string/sentence of words. Output Format: • Each line of the output should print the index number and words in it, separated by a colon(:). • The words inside a group are separated by minus sign(-). • If no words are present in the group then print ‘null’ in place of words. Sample Input 1: 3 Write a program to create a hash table. Sample Output 1: 0:create 1:Write-a-program-to-hash-table 2:null Sample Input 2: 5 This program is a program to create a hash table Sample Output 2: 0:table 1:This-a-create-hash 2:null 3:null 4:program-is-to
Can anybody help me with this?
Alfredo
Can anybody help me with this?
Read the rules. https://t.me/programminginc/283193 What have you tried?
IAmMADMAX
Can anybody help me with this?
Sorry I have tried but not able to find the logic can anybody help?
IAmMADMAX
Its one in leetcode but i cant find the question
IAmMADMAX
what have you tried?
Mess mine is a mess one
MᏫᎻᎯᎷᎷᎬᎠ
match(it): A light-weight header-only pattern-matching library for C++17. https://github.com/BowenFu/matchit.cpp https://redd.it/nzoc97 @r_cpp
Anonymous
hello every one
Anonymous
please i need help i have a c project to write a c program that is able of converting numbers to word like 100 and the output is one hundred any hints please
Pavel
please i need help i have a c project to write a c program that is able of converting numbers to word like 100 and the output is one hundred any hints please
You can first split the value into array of digits, and fill additional (3-size%3) elements with zeroes. So for 1234 it will be { 4, 3, 2, 1, 0, 0 } Then you can reverse iterate over each three elements and decide what you want to output. You will also need a function that converts a digit to a string depending on the position in the triplet. Also a function that will return correct string for the given index of a triplet ("thousand", "million") So in my case I would do two iterations, for first process 0, 0, 1 and output "one thousand " The second iteration would be 2, 3, 4 and something like "two hundred thirty four "
Ammar
pthread_join function changes the state of the pthread_t struct it gets as argument?
It can't change the pthread_t it gets as argument because it doesn't have a reference to it. The argument is passed by value, it means it only receives a copy of it.
Danny
morng
Sandro
Hi guys, how to connect to Google services like contacts with C? There is some library or some code to do it?
Murugaa
Heloo sir
Murugaa
I have a question
olli
Hi guys, how to connect to Google services like contacts with C? There is some library or some code to do it?
Google Contacts is deprecated and superceded by People. Google offers a REST API that you can use with basically any programming language that supports network calls. To connect to it you probably want to use OAuth2.0 to authenticate the user and use the provided token for subsequent requests https://developers.google.com/people
Apk
scanf("%d ",&a); Why does adding a space after %d makes the program wait for more input?
Kwabena
Hi Good morning family
None
(Find the Smallest) Write a c program that finds the smallest of several integers. Assume that the first value read specifies the number of values remaining
klimi
Just doing some practise....
okay.... and why have you send the message then if you are practicing?
Anonymous
Showing us the error might help us further assist you though