Anonymous
But with the friend function we can easily access private data of the friend classs
Anonymous
So it contradict the concept of oops ...?
Shourya
But with the friend function we can easily access private data of the friend classs
Read the article ...Friend is as good as member function if used properly. ...Think of it as your bike key ..Only you or your friends (with whom you share your bike key) can unlock bike
Shourya
Okay i have bit confusion what the use of friend function if we have inheritance .. feature..
Hard to explain all the stuff here ..But try operator overloading in c++ ..You will get the essence of friend funcs
Anonymous
Okay bro thanks
Anonymous
hello, how to make a stack based on the weight of the items in it?
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
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!
Anonymous
trynafindanu
Write syntax of strlen(), strupr(), strlwr(), gets(), puts()
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
Can anybody please help me?
check out cppreference
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 ? 🙂
Hussein
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
those are called manpages provided by the system to help programmers it will tell you how each function is used and give you tips and warnings about how to use them and stuffs like that
Puspam
C program actually It's my question for exam 🥲
So, you should learn, research about those & then answer the question.
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
Hussein
Why gets should not be used?
Because you can easily cause a buffer overflow without any possible method to prevent it from happening
Hussein
Hi can i get someone's help in a simple quiz pls ? 🙂
We can help solve the problems in your quiz so you can learn
Hussein
C program actually It's my question for exam 🥲
just google “C standard library tutorial” or just google the functions you want to learn about
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
Sefax
Thank You
Anonymous
What is -1.#IND00 ? I get this in c
https://stackoverflow.com/questions/347920/what-do-1-inf00-1-ind00-and-1-ind-mean
Anonymous
Is friend function distroy the concept of oops ?
With friends class we can access 1 class data with 2 class
Submissive
With friends class we can access 1 class data with 2 class
Whether can we access protected data in class?
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
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
Hi, How to safe programming in c ?!
How to program safely in C?
Nice Doge
What is your one book / course recommend for begineer?
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
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
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
Iwan
I can run this code correctly, it not your code's fault.
Yea, me too. I run it on restesterbot, and the code is work.
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..
Anonymous
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..
A constructor is more than just the body you provide it as is the case for the destructor. A constructor will allocate memory for the data members of the class (this is done automatically for you by the compiler when it compiles the constructor) but this is done before the body of the constructor is entered. The initialization list of the constructor is executed before the body of the constructor executes. For a const data member, giving it a value in the body of the constructor is actually assignment rather than initialization. You can't assign to a const data member. Hence it must be initialized using the initialization list of the constructor.
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