Talula
overload...
Roy
Hello guys, hope all is good. I got a question regarding data structures and OOP in C++. If I defined a template class list and defined public virtual functions in it. template <typename W> class list{ public: virtual functions }; Then I created a public class called Arrays and written it as following template <typename W> class Arrays: public list<W>{ Attributes + overriding the function }; How can I create an array in the main of type Arrays to be filled with characters. I wrote Arrays<char> arr = new Arrays();
Roy
I am getting an error that I can't declare an object of abstract class type Arrays<char>
Roy
Can anyone help me with this error?
Anonymous
Hello guys, hope all is good. I got a question regarding data structures and OOP in C++. If I defined a template class list and defined public virtual functions in it. template <typename W> class list{ public: virtual functions }; Then I created a public class called Arrays and written it as following template <typename W> class Arrays: public list<W>{ Attributes + overriding the function }; How can I create an array in the main of type Arrays to be filled with characters. I wrote Arrays<char> arr = new Arrays();
Means there are some pure virtual functions left unimplemented in the derived class. As long as there are some pure virtual functions that are not defined, your derived class will be still considered as an abstract class. Show us the full code using a pastebin site. Btw Arrays<char> arr = new Arrays(); is not correct C++ syntax. It should be Arrays<char> arr or auto arr = new Arrays<char>{}
Roy
https://pastebin.com/6vghZriR
Roy
these are the two classes
Anonymous
https://pastebin.com/6vghZriR
Like I said there are methods that are not implemented in the derived class like begin and end for example. Look up your favorite search website for the contextual keyword override and use it in your code as well. That would catch errors related to signature.
Roy
okay will try to comment the functions in the class and run the code
Roy
as you saw the default constructor accepts the size as a parameter, how can i declare an object of type Arrays in the main I wrote Arrays<char> arr = new Arrays(max);
sushi
Can I ask if how am I gonna sort 100 random numbers in c++?
sushi
Btw, i'm using srand
Void
DEFGHIJK*
Void
I wonder why there is "*" in the string when output the solution and how to remove it
the best for everyone
Unknown
I am writing a mode function using C++, but the thing it doesn’t work with multiple modes, so if there are more that one mode in the array it will only print the first one.
Anonymous
Hi everyone i have some problem anybody can help?
Anonymous
Any coding ninja coder here
C
Any coding ninja coder here
what is a coding ninja?
Муртазо
what is a coding ninja?
I think one who knows programming well:)
Ludovic 'Archivist'
what is a coding ninja?
Probably someone that uses the code ninja platform (the shittiest CS MOOC ever made)
Ludovic 'Archivist'
I will allow you to post links, wait a sec @zabnicola
Ludovic 'Archivist'
Ok
Bigissue
Hi, Ok, I have problem with qt c++. https://pastebin.com/adWHq16v My problem is attempt to display an image from base64 string. It doesn't show me full image. Why? Thank you for help me.
Unknown
I am writing a mode function using C++, but the thing it doesn’t work with multiple modes, so if there are more that one mode in the array it will only print the first one. Any suggestions?
Anonymous
I am Currently writing a school management system using C++ Where the Teacher Can 1.Add Student 2.Search Student(using StudentID) 3.Modify Student Record 4.Delete Student I have used Structures(with an Array) to define Students... So the problem i am facing is that once i add a Student after the other, the one Program stores only the Second student rather than both. How can i make the program store many students😔?
Unknown
It’s better to send the code.
Because It’s not clear why only the second student stored
Anupam2.7
Can friend function be void function?
а
does anyone saw GTK4 example? wtf
Евгений
Hey guys, if someone has some books related to MASM, please share them. Thanks.
Yui
type __sync_lock_test_and_set (type *ptr, type value, ...) This built-in function, as described by Intel, is not a traditional test-and-set operation, but rather an atomic exchange operation. It writes value into *ptr, and returns the previous contents of *ptr. Many targets have only minimal support for such locks, and do not support a full exchange operation. In this case, a target may support reduced functionality here by which the only valid value to store is the immediate constant 1. The exact value actually stored in *ptr is implementation defined. This built-in function is not a full barrier, but rather an acquire barrier. This means that references after the operation cannot move to (or be speculated to) before the operation, but previous memory stores may not be globally visible yet, and previous memory loads may not yet be satisfied.
Yui
how to understand the last sentence?
Yui
what does [previous loads may not yet be satisfied ] mean?😟
Anonymous
type __sync_lock_test_and_set (type *ptr, type value, ...) This built-in function, as described by Intel, is not a traditional test-and-set operation, but rather an atomic exchange operation. It writes value into *ptr, and returns the previous contents of *ptr. Many targets have only minimal support for such locks, and do not support a full exchange operation. In this case, a target may support reduced functionality here by which the only valid value to store is the immediate constant 1. The exact value actually stored in *ptr is implementation defined. This built-in function is not a full barrier, but rather an acquire barrier. This means that references after the operation cannot move to (or be speculated to) before the operation, but previous memory stores may not be globally visible yet, and previous memory loads may not yet be satisfied.
The last sentence means that this function uses memory_order_acquire semantics. Say you are working on a processor with TSO semantics. This processor will have a write buffer to store its local writes. So any write executed on this processor will get stored in the buffer and will get propagated to other processors/cores at a later time. So any write done by this processor may not be visible to other processors even when the write to *ptr using sync_lock_test_and_set is visible. That is what acquire semantics means. However acquire semantics also guarantees that speculative operations following this atomic operation cannot be moved ahead of this operation itself. So a processor is not allowed to do a speculative load for an operation that follows this atomic function before the effects of this atomic function and the operations before it are completely propagated to all processors/cores. The sentence "previous memory loads may not be satisfied" means that this operation if not synced with a corresponding release operation may work with speculative loads i.e. loads from a processor's local cache without the cache being synced up between processors. The values in the cache may not be marked as invalid even when some other processor has changed it in its own cache before the call to this function
Yui
ah... I see.. thanks !!
Anonymous
ah... I see.. thanks !!
I am surprised that they chose the name test_and_set though.
Yui
so the test_and_set actually tested what? the valid flag in cache?
Anonymous
so the test_and_set actually tested what? the valid flag in cache?
No. I am saying that the name for the function is wrong. It is just a plain exchange operation. A test and set operation will typically check the current value and take an action based on that value. This operation doesn't seem to be doing that.
Anonymous
Yui
learned a lot🥰
M
Is it possible to build voice recognition app using C++?
Yui
Is it possible to build voice recognition app using C++?
find an api, and use http to post and get voice data via api
Ольга
https://onlinegdb.com/Vl3rLxBoX Good afternoon, I need help with this matter. I don't understand how to link class and structure correctly, I tried to do it in line 20, but I'm clearly doing something wrong. I will be grateful for your help
Гулящий
Tip 1 for New Programmers: use https://godbolt.org/ when you have to show code to someone.
Гулящий
Tip 2: you need to erase excess spaces in scanfs. Like this: scanf("%d",&a); Read this to understand more: https://stackoverflow.com/questions/20306659/the-program-doesnt-stop-on-scanfc-ch-line-why
Гулящий
Thank You! You Just Saved me mate
Tip 3: good luck and don't lose hope)
Kay
****a ***b **c *d e Who know how to solved this by using nested for loop?
Kay
In C language
Captain
Please I really can't understand how class can have struct in itself
Create struct outside the class and have struct object in class
dej
Hello guys, I need some help with my project. I’m building a private chat and I have some problems with sending and receiving messages. Can anyone help me? Can I attached my GitHub link of project?
dej
Attach*
Ольга
Unknown man
****a ***b **c *d e Who know how to solved this by using nested for loop?
/* */ #include<stdio.h> int main() { int i,j,a=97; for(i=0;i<5;i++) { for(j=0;j<5;j++) { if(j<4-i) { printf("*"); } if(j==4-i) { printf("%c",a); a++; } else { printf(" "); } } printf("\n"); } return 0; }
Gain
list<bool> *l = new list<bool>[V]{0} ; bool *l =new bool[V]{0}; What's the difference between these two ? I want to initialise a array of length V containing boolena values
Arvin
Hello guys, I need help to do an input instruction such as std::cin but without entering a new line. Can I do that (in C++)?
Anonymous
Arvin
Use getche() in a while loop until the character where you wanna stop is entered
Thank you I am using just iostream for now, do I have to add any other lib to use getche()?
Arvin
getche is defined in conio.h I think
Oh right, it works Thank you
Anonymous
Thanks 🙏
Ludovic 'Archivist'
https://godbolt.org/z/sEqvjcfbW maybe this link will be more comfortable for someone
I think you should start by getting a more solid grasp on functions and types before you write your own types with struct/class/enum
Abel
#help int hasilPerhitunganDeret(int hasil[]); int main() { const int n = 5; int deret5Angka[n] = {1,2,3,4,5}; int hasil = hasilPerhitunganDeret(deret5Angka); std::cout << hasil; return 0; } int hasilPerhitunganDeret(int hasil[]){ for(int i = 1; i <= 5; i++){ if ( i == 0 || i == 1){ hasil[i] = i; return hasil[i]; }else{ return hasil[i] + hasilPerhitunganDeret(hasil[i-1]); } } } Error: argument of type "int" is incompatible with parameter of type "int *"
Gain
One is an array, the other is a list
if i push_back only once in the list can i use it as an array like the second case?
Anonymous
if i push_back only once in the list can i use it as an array like the second case?
No, a list is totally different from an array. Look up the functions associated with an STL list. The biggest downside is that a list doesn't have random access, so using [n] to access n+1th element won't be possible. Maybe you should look into vectors
Gain
means each array element stores a pointer to a list
Ольга
I think you should start by getting a more solid grasp on functions and types before you write your own types with struct/class/enum
Тhanks for the advice. I understand that I do not understand much about this topic. But, unfortunately, the task must be performed