Olivia
It throw error as vector has no member named as shrink to fit
Olivia
It doesnot name a type
Olivia
Also it was not declared in the scope🥲🥲
Konstantin
maybe you use old compiller
Olivia
Aww thats i was suppose to know thankyou sir
Konstantin
https://onlinegdb.com/t8PGKzuVB
Olivia
Is it new compiler??
Konstantin
it works for me
Konstantin
with my little changes
Olivia
Can u suggest me new compiler as u can see i am new
Olivia
In this field like i'm beginner
Konstantin
You can try latest VisualStudio with C++
Olivia
Dev c++😅😅
Dima
Dev c++😅😅
don’t use this, anything else is better than this
Olivia
DaviChan
Isnt is good??
No its actually fine. Especially for beginners. Its light weight, good ide, portable and also has cmake project support I think. So all you really need.
Honestly IDEs are 99% preference, but i gave my gf this IDE also to learn C++ and it looks very good.
Personally i dont use IDEs
Olivia
Aww i got it
Olivia
Sir 🙂
neovstan
Olivia
neovstan
Can u tell me the difference between reference and pointer😅😅in simply
There are a lot of explanations for beginners. Your question is formed correctly, just google it. Google is the best helper for a developer.
Anyway, a reference cannot be uninitialized. It always points to a correct data (almost, but you don’t have to care about it at this step)
B4H
Hey guys ,I have a concern in my program .So if I passed two objects for a function like func(obj1,obj2) which one is supposed to get destructed first??!
B4H
isnt it supposed to destruct obj2 first??
Anupam2.7
are INT_MAX and INT_MIN some constants in c++?
neovstan
B4H
Anupam2.7
klimi
is it really defined like that? like the order of initialization of the parameters
B4H
B4H
#include <iostream>
#include <cmath>
using namespace std;
class clockType
{
public:
~clockType();
clockType(int =0,int =0 ,int =0);
void setTime(int h, int m, int s);
void getTime(int& h, int& m, int& s) const;
void printTime() const;
void tick();
private:
int hour;
int minut;
int second;
};
clockType::~clockType()
{
cout << "destruct : " ;
printTime();
}
clockType::clockType(int h, int m, int s) :hour(h), minut(m), second(s)
{
cout << "constract : " << endl;;
}
void clockType::setTime(int h, int m, int s)
{
hour = h;
minut = m;
second = s;
}
void clockType::getTime(int& h, int& m, int& s)const
{
h = hour;
m = minut;
s = second;
}
void clockType::printTime()const
{
cout << hour << " : " << minut << " : " << second << endl;
}
void clockType::tick()
{
second++;
minut += second / 60;
second = second % 60;
hour += minut / 60;
minut = minut % 60;
hour = hour % 24;
}
int fun (clockType OPJ)
{
int hr, min, sec;
OPJ.getTime(hr, min, sec);
return (sec + 60 * min + 60 * 60 * hr);
}
bool isGreater(clockType OPJ1, clockType OPJ2)
{
int second1 = fun(OPJ1);
int second2 = fun(OPJ2);
if (second1 > second2)
return true;
else
return false;
}
int main()
{
clockType clk1(2, 10, 10);
clockType clk2(2, 20, 10);
cout << isGreater(clk1, clk2);
}
B4H
#include <iostream>
#include <cmath>
using namespace std;
class clockType
{
public:
~clockType();
clockType(int =0,int =0 ,int =0);
void setTime(int h, int m, int s);
void getTime(int& h, int& m, int& s) const;
void printTime() const;
void tick();
private:
int hour;
int minut;
int second;
};
clockType::~clockType()
{
cout << "destruct : " ;
printTime();
}
clockType::clockType(int h, int m, int s) :hour(h), minut(m), second(s)
{
cout << "constract : " << endl;;
}
void clockType::setTime(int h, int m, int s)
{
hour = h;
minut = m;
second = s;
}
void clockType::getTime(int& h, int& m, int& s)const
{
h = hour;
m = minut;
s = second;
}
void clockType::printTime()const
{
cout << hour << " : " << minut << " : " << second << endl;
}
void clockType::tick()
{
second++;
minut += second / 60;
second = second % 60;
hour += minut / 60;
minut = minut % 60;
hour = hour % 24;
}
int fun (clockType OPJ)
{
int hr, min, sec;
OPJ.getTime(hr, min, sec);
return (sec + 60 * min + 60 * 60 * hr);
}
bool isGreater(clockType OPJ1, clockType OPJ2)
{
int second1 = fun(OPJ1);
int second2 = fun(OPJ2);
if (second1 > second2)
return true;
else
return false;
}
int main()
{
clockType clk1(2, 10, 10);
clockType clk2(2, 20, 10);
cout << isGreater(clk1, clk2);
}
For this code in IsGreater function ,OBJ1 got destructed first .why that happened?!
Anupam2.7
B4H
N
Can anyone give some great c++ idea inspiration
neovstan
klimi
but if you don't know the order of initialization you don't know the order of destructing also no?
B4H
Why it didnt?I dont understand how clk2 has anything to do with this
neovstan
Thank to God, there is no reason to know this order.
B4H
N
Write own vector
Like you could you give an example i didn't understand it like creating my own libary!?
DaviChan
Anonymous
Hey does anyone in here build modules for node? I’ve been compiling multi platform binaries and for some reason the binaries are only recognized on the host and not the target. (If out of topic sry)
\Device\NUL
\Device\NUL
Asker
\Device\NUL
MirfayzMukhsinov
Hello Everyone, Can you help me.
MirfayzMukhsinov
Let me write if anyone knows the Mastermind game
MirfayzMukhsinov
Who can.please
Morax
I am implementing a stack which contains characters. I have defined a function pop which returns void and doesn't take in anything as parameter. But while executing the code, i accidentally gave a character while calling pop(), and the code worked just fine without throwing an error. How is this possible?
Morax
Something like pop(exp[i]) where exp is a char array..
Anonymous
Hey everyone
Anybody can help me in the understanding of operator overloading
Гулящий
Гулящий
Imagine you wrote a class Student.
Imagine you have a vector of Students and wish to sort it.
Alphabetically, let us say.
But how do you compare them?
You can embed the comparison inside your sorting algorithm. But that does not look nice at all.
So much finer would it be, if only you could write something like this:
if(students[i]> students[i+1]){ //student at position i should alphabetically be after student at position i+1
//Swap 'em
}
That's when our friend operator overloading comes in.
Гулящий
Гулящий
Yeah, part of it, but that's not the point.
smene
Гулящий
Morax
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
In file included from /usr/include/unistd.h:217,
from client_header_basic.h:2,
from client_header_functions.h:1,
from client_functions.c:2,
from client_main.c:1:
/usr/include/x86_64-linux-gnu/bits/types.h:31:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘typedef’
31 | typedef unsigned char __u_char;
| ^~~~~~~
In file included from /usr/include/stdlib.h:394,
from client_header_basic.h:5,
from client_header_functions.h:1,
from client_functions.c:2,
from client_main.c:1:
/usr/include/x86_64-linux-gnu/sys/types.h:33:9: error: unknown type name ‘__u_char’
33 | typedef __u_char u_char;
Hi guys, the gcc gives me this error. What does it mean? I tried the software yesterday and it worked just fine without any problem whatsoever, today this happened (it's a C program btw, I use WSL + gcc)
ABHIJITH
HI, I'm confused about the following syntax while reading source code of an open source project.
typedef Pair *(*PairCreator)(LAMMPS *);
typedef std::map<std::string, PairCreator> PairCreatorMap;
PairCreatorMap *pair_map;
template <typename S, typename T> static S *style_creator(LAMMPS *lmp)
{
return new T(lmp);
}
pair_map = new PairCreatorMap();
(*pair_map)["lj/cut"] = &style_creator<Pair, Class>
I can't understand what is "(*pair_map)["lj/cut"]". I believe it is a function pointer of some sort as it is assigned memory of a function "style_creator". But I don't understand how a class instance "pair_map" is indexed with string. Is there any material or reference where I can look for this syntax?
I searched a whole day on google but can't find anything similar.
Doreece
Hi I have a problem with the code written below:
#include <stdio.h>
int main(){
int a,b;
scanf("%d %d",&a,&b);
int c = b>>(a-1);
c=c%10;
printf("%d",c);
For example if a=3 and b=1056
It should return c as 0 but it returns 4
Any idea how to fix it ?
Anupam2.7
what is wrong with this palindrome program in c++?
https://onlinegdb.com/eaupEg-sO
olli
olli
Doreece
Doreece
Doreece