Anonymous
But with the friend function we can easily access private data of the friend classs
Anonymous
So it contradict the concept of oops ...?
Anonymous
Anonymous
Okay bro thanks
Anonymous
hello, how to make a stack based on the weight of the items in it?
● Igor
Anonymous
what does that mean?
I want to create a stack where the input data limit is based on the value of the variables in it, for example max stack = 40, the variables in it for example a = 10, b = 30. then if you want to input variables again you can't because a + b = 40, max = 40
● Igor
● Igor
you can create a variable to store the sum (weight) and update it after every push/pop
Anonymous
Hello guys! Can someone help me write a C Program about these:
1. If a is greater than 10, replace a with the difference of a and b.
2. If b is odd then display the value of b/2. Otherwise, display the message 'b is even number'.
I would really appreciate if someone will help me with this. Thanks!
klimi
Anonymous
Anonymous
trynafindanu
Write syntax of strlen(), strupr(), strlwr(), gets(), puts()
trynafindanu
Puspam
Can anybody please help me?
You can just search for examples on Google. That way you will get to know in details about each of them.
klimi
Hussein
Can anybody please help me?
are you using linux?
if yes just write this in the terminal:
man strlen
man strupr
man strlwt
man puts
man gets <— never ever use this
~ shiinnraa
Hi can i get someone's help in a simple quiz pls ? 🙂
trynafindanu
Puspam
Puspam
Shourya
Why gets should not be used?
Gets is still there I thought it was removed from C11standard ..can cause buffer overflow as there is no bound test on input
Puspam
Hussein
Why gets should not be used?
Because you can easily cause a buffer overflow without any possible method to prevent it from happening
Anonymous
What is -1.#IND00 ? I get this in c
Anonymous
Hello guys? I input .2f so that it will include only 2 decimals. Why is that the output keeps on only printing the whole number? Please give an advise. Thanks
Anonymous
Sefax
Thank You
Submissive
LD
Hi, I'm looking for a C++ expert to tutor me and help me understand some code and classes. Please DM me if interested
浩
Hello, I am compiling a program with msvc, which can be compiled with gcc and clang correctly, but msvc raise an error saying the following:
浩
random.cpp.obj : error LNK2005: "struct TAT::FastName const $S37" (?$S37@@3UFastName@TAT@@B) 已经在 .dealing_tensor_FermiU1_C.cpp.obj 中定义
random.cpp.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const $S38" (?$S38@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B) 已经在 .dealing_tensor_FermiU1_C.cpp.obj 中定义
sorry my system is chinese, the chinese inside means "xxx have alreadly be defined in yyy", of cause, you can know what it means by the code LNK2005
浩
I never defined a function or variable with names "$S38", what is it?
浩
I have already add inline to every function and variable in header file to let it can be compiled with gcc and clang.
Shourya
C++ version?
Shourya
Shourya
Inline should solve the problem ..May be you can force in project setting to generate code even of violating odr
浩
浩
Shourya
it seems not a good practice?
Yes not a good practice ..But as your code compiles in gcc so in reality it may not breaking be odr ...Or may be you can get old way using namespace for your variables or externs ...
浩
Vlad
Nice Doge
What is your one book / course recommend for begineer?
Hussein
Fenimoure
Why do I call destructor R[i].~ClassRoom(); but the program still outputs the rooms?
R:
Room: 1 7 1
Room: 2 4 4
Room: 3 9 1
Room: 4 2 4
Output sequence is being processed after calling the destructor
Vlad
Fenimoure
Vlad
Fenimoure
Vlad
Destructor shall be called by the end of scope
Fenimoure
Destructor shall be called by the end of scope
I need to manually delete it, because I am "shifting" an element from structure array "R" to a different structure array "Comp". This means, I have to copy the element to "Comp" and delete it from "R"
Vlad
Vlad
Or better yet move whole buffer around
Fenimoure
Vlad
If you have C style on the stack arrays then you are out of luck
Vlad
They can't be moved nor deleted
Fenimoure
It is C++
ClassRoom R[] = {{1, randomSize, randomSize},
{2, randomSize, randomSize},
{3, randomSize, randomSize},
{4, randomSize, randomSize}};
Here is what I am working with
Ster-Devs
It has been a long time since I've code with C++ so I didn't know that we can create array of object like that 😅
Shourya
Hi all .. I left C++ development like 5 years ago ..but my new project n code base provided requires some real hardcore C++20 .. ...I need to catch up very very fast ..there strict time limit max 2 days ..I know I can always refer the official documention but there is no time to look n code ...anyone knows any good course that I can refer ..youtube udemy pluralsight I have checked and found some but need some genuine feedback so that time is not wasted ..!let me know if you have any suggestion
Anonymous
hey guys, can u help me??
Anonymous
#include<iostream>
using namespace std;
int main(){
int x,y,z;
cin>>x;
z=0;
for(y=1;x>=y;++y){
if(x%y==0){
z=z+1;
}
else{
continue;
}
}
if(z==2){
cout<<"prime";
}
else{
cout<<"not prime";
}
return 0;
}
Anonymous
this code was not taking x variable input from user
Anonymous
Can some provide me c programming course
Anonymous
Or lecture notes with proper algorithm
浩
Anshul
Does constructor allocate memory to member variables?
I read something like this
"if I have a const data member inside a class, then I have to use initialiser list because assignment is not possible and as memory for data members is not allocated until constructor is called so using initialisation list , will be initialising our member variables and not assigning."
This is true so either constructor allocates memory to member variables or something else is happening here..
Anshul
Anonymous
Pavel
Yo boys . My compilar stop workin on unbuntu the last one version after update. Also i cant update repository on my ubt. Can u help me ? Btw pycharm with python still workin