Fetheddine
void Personnage::recevoirDegats(int nbDegats)
{
m_vie -= nbDegats;
//On enlève le nombre de dégâts reçus à la vie du personnage
if (m_vie < 0) //Pour éviter d'avoir une vie négative
{
m_vie = 0; //On met la vie à 0 (cela veut dire mort)
}
}
Fetheddine
void Personnage::attaquer(Personnage &cible)
{
cible.recevoirDegats(m_degatsArme);
//cible.m_vie-=m_degatsArme; est ce qu'on peut faire ca !!
//On inflige à la cible les dégâts que cause notre arme
}
Fetheddine
Fetheddine
cible.recevoirDegats(m_degatsArme); by the comment which is this
Fetheddine
cible.m_vie-=m_degatsArme;
Fetheddine
i mean can i have acces to anonther object from the same type because the compiler doesnt show any error when i did it is that correct
Fetheddine
my question is
Fetheddine
can i get access to an attribute of an object sent as argument by reference (adress) in c++ while creating class
pavel
Fetheddine
#ifndef DEF_PERSONNAGE
#define DEF_PERSONNAGE
#include <string>
class Personnage
{
public:
Personnage();//constructeur
~Personnage();//destructeur
Personnage(std::string nomArme,int degatsArme );
void recevoirDegats(int nbDegats);
void attaquer(Personnage &cible);
void boirePotionDeVie(int quantitePotion);
void changerArme(std::string nomNouvelleArme, int degatsNouvelleArme);
bool estVivant() const;
private:
int m_vie;
int m_mana;
std::string m_nomArme; //Pas de using namespace std, il faut donc mettre std:: devant string
int m_degatsArme;
};
#endif
pavel
Than you can't (except friend classes)
Fetheddine
Fetheddine
thats it !
Fetheddine
Thank you
Fetheddine
But why why i didnt get any error or it will appear when icall the function in main
pavel
You can see https://en.cppreference.com/w/cpp/language/access at the end of page "Private member access"
Fetheddine
数学の恋人
Null
Suggest Course to learn c and c++
L
Go through all the rules and the links mentioned in this post. Contravening the rules laid out here will result in a warning (least likely) or a ban (most likely).
This group is meant only for C/C++ discussion.
For chitchat of any other kind, go to the Offtopic chat, where anything unrelated to C/C++ programming can be discussed subject to the rules laid out for that group.
For information on learning C/C++, see our list of resources at @Resources
RULES:
1. Only English language is allowed. If you don't speak English, then this group is not for you. Please look elsewhere.
2. This group is meant to be used for C/C++ discussions alone. Assembly language discussions are allowed as well. The moderators' intention is to keep this group clean and to stick to the purpose the group was created for. Hence, questions or discussions about anything else is strictly forbidden. This further means that:
• You should not send useless messages like "Hi"/"Hello", "I'm new here" and similar.
• You should not send useless messages like "Does anyone know XYZ?", "Has anyone used XYZ?". Just ask your question directly.
• You should not ask questions without checking your problem in Google or any other search engine. Doing so will result in a warning. Following this, check the Resources section of this group to see if your question has an answer there.
• You should not ask exams/homework/interviews solutions. This will get you banned.
Asking for something that is there in the pinned message right after joining will get you banned.
3. NSFW content (porn, nudity etc) is not allowed.
4. Religion, politics and ideological topics are forbidden.
5. A little bit of programming related jokes and memes are allowed subject to admin group's discretion.
6. Advertisements of any kind are forbidden. Job postings will not be allowed either. If you are unsure about whether something could be construed as an advertisement, please check with one of the admins before posting the message. Not doing so will result in a ban.
7. Code sharing is encouraged subject to the following rules:
• Try to use markdown formatting.
• For many lines (10+) of code, use a pasting service like Gist, Pastebin, Ubuntu Paste, Hastebin. Don't post walls of code in the chat window. Firstly, it inconveniences others and secondly, you are unlikely to get a response and may even get warned or banned.
• Don't attach photos or videos of your screen. Screenshot captures are ok.
8. No illegal activity. This also means no piracy, no requesting/offering hacking/no posting of compiled executables. This will result in an immediate ban.
9. Respect people's privacy. Don't send private messages to people in this group without taking their permission to do so. Not following this rule will result in an immediate ban.
10. Avoid usernames that affects chat readability.
The group bot Rose offers a lot of readymade responses that can be used when replying to someone. The most commonly used ones are:
• #paste - Display a list of sites where code can be shared.
• #markdown - Learn how to use markdown formatting.
• #res - Post the link to the C/C++ resource collection.
• #meta - Tell someone to get to the point!
• #howtoask - Tell someone how they should ask a question.
• #ot - Tell someone that their question is off-topic and hence must be moved to the OT group.
check the resources
legend
guys, I'm new here. How Long does it take To Learn C++ programming language?
Painter👨
legend
thanks dude
“👨🏻💻” Ahmed;
Hussein
31 hours , if you gonna watch FreeCodeCamp course youtube)
You mean 93 hrs because you will pause the video a million times to understand each concept then move on to the next
Then you will finish only the basics😂
After that you have to follow the traditional way of programming to assume that you know everything and you have mastered the language then start working on a project until you start secretly googling your errors and learn from your mistakes
Painter👨
Faramarz
struct customer
{
char* lname;
int numOfTicket;
int lineNum;
int time;
};
struct node
{
struct customer* cptr;
struct node * next;
};
struct queue
{
struct node* front;
struct node* back;
};
Hi everyone, in my assignment I'm required to use this 3 structures to create several linkedlist queue(12) and I need to insert data into struct customer at the bigening, because of having multiple structure I've got confused, is it possible to give me some hints about building those queue and fill them up?
Thank you
Hussein
Hehe boii😁 yep
I can assure you that every programmer (not very proudly including myself) at some point has followed the traditional way of programming
This is part of the natural life cycle of programmers nothing to be ashamed of ;)
三体183号
三体183号
Just insert, delete, sort and other operations
三体183号
fifo
三体183号
But it is a discontinuous storage structure
三体183号
If you want to get the data, it means that the data should be removed from your team
三体183号
I think you can use STL to solve this problem.
Zuhair
How to looping this number?
A. 0 2 4 6 8 0 2
1 3 5 7 9 1 3
2 4 6 8 0 2 4
3 5 7 9 1 3 5
Zuhair
How to looping this number?
0 2 4 6 8 0 2
1 3 5 7 9 1 3
2 4 6 8 0 2 4
3 5 7 9 1 3 5
pavel
👾
👾
AKI David
legend
Iwan
AKI David
Hussein
AKI David
Done
AKI David
#include <stdio.h>
int main()
{
int x= 0;
for(int i = 0; i<4 ;i++)
{
int old = x;
x = x+i;
for(int k=0;k<i;k++){
printf(" ");
}
for(int j= 0; j<7; j++)
{
printf("%d",x%10);
x = x+2;
}
printf("\n");
x = old;
}
}
AKI David
Done
I nested the for loop and used the i iterator to count the number of spaces
AKI David
\Device\NUL
\Device\NUL
Just because the compiler doesn't complaining about indentation, it doesn't mean good. You will be messed up if you have a big project
Hussein
yeah but in telegram you have to use spaces which really suck
pavel
Like this
int a;
\Device\NUL
Muhammad Ali
#question #fraction
Hi everyone, is there a method in c++ to convert a number to fraction?
such as in python:
from fractions import Fraction
print(Fraction("0.5"))
-----
Output: 1/2
Elroy
No there isn't, you just have to write one yourself.
Ster-Devs
AKI David
● Igor
any tips for testing code during a contest where you can't use external libs (only std)?
i'm using assert.h to create very basic unit tests
Roxifλsz 🇱🇹
This is a bit offtopic, but if it's on github, I think you can only close pull requests, not delete them
Anonymous
Hy guyz! Actually, i'm beginner for C++.
So i wanna ask that what type of math is required for c++.
Anastasiia
Hi guys, does anyone know C libraries with Laplace integral calculation?
pavel
Anastasiia
pavel
Hussein
WTH!!! I pasted a link to off topic chat of this group
why I’m getting a warning?
Dima
Dima
or are you talking about posting another link in ot?
Dima
try using spaces
Hussein
Ok thanks
Anonymous
Could you please introduce me some resources to developing a decentralized network in C/C++?
Anonymous
No “Blockchain” sh*t, I mean developing something that users are the servers and controlling data via a central client.
pavel
Andrew Stuart Tanenbaum computer networks? Maybe gamasutra will help you too
Anonymous