Chat:World/2022-01-21

From CG community
Jump to navigation Jump to search

Default avatar.png NovaSHPP: it's hard, but fun

Wontonimo: ah

Default avatar.png oiweg: hi guys

Default avatar.png TheUndyingClown_f05: hi daddy

Default avatar.png ladN: :*

Default avatar.png oiweg: what is your name?

Default avatar.png oiweg: :rage:

Rebollo: :slight_frown:

Default avatar.png oiweg: :flushed:

Rebollo: Folks, what if I have this class structure:

Rebollo: Class A {}

Default avatar.png oiweg: ITS MEAN THAT U R FAY

Default avatar.png oiweg: GAY*

Default avatar.png oiweg: just joke

Rebollo: And you are ature

Default avatar.png oiweg: sry

Rebollo: mature

Rebollo: np

Rebollo: Class A{}

Class child1 : public A{} Class child2 : public A{}

Rebollo: And a Need to print its childs contents

Rebollo: having a array o A

Rebollo: But each of the childs require diferent logic on print function because the are different types

therealbeef: you have an array of A or pointers/references to A?

Rebollo: the Array contains child1 and child2

therealbeef: hmm, is this about c++?

Rebollo: yes

Rebollo: Class A (parent) Class child2 Class child2

Rebollo: Array of type A = [child1Obj, child2Obj]

Rebollo: would like to call

therealbeef: that's impossible :)

therealbeef: all elements of an array have to be of the same type

Rebollo: A[0]->print()

kurtesy: Aloha

therealbeef: it's useful to distinguish two different kind of types: static type and dynamic type. Static type is what you actually say it is in the code. Dynamic type is what the object actually is in memory. so when you have std::array<A*, 2> you get an array where all elements have static type 'pointer to A'. But they can have dynamic type child1 and child2: std::array<A*,2> = {&child1Obj, &child2Obj};

Rebollo: like this right?

Rebollo: http://chat.codingame.com/pastebin/826d7f0c-86fd-4551-8f25-7f11b1213f76

Rebollo: This works

Rebollo: different types in the same array

Rebollo: Now how can I genericly print their values, onde they have different properties?

Rebollo: once*

therealbeef: In your code the array consists of objects of type Area (not pointers). When you then assign an object of type Grass to it, it converts the gg object to an Area object, so area[1] is not pointing to the gg object

therealbeef: polymorphism only works through pointers or references

Rebollo: :nerd:

therealbeef: Area** array = new (Area*)[10]; array[0] = bb; array[1] = gg;

Default avatar.png BobaAndBiba: hi i Boba , your ban my brother Biba, i angry:rage::rage:, За россию !!!!!:flag_ru::flag_ru:

Rebollo: OMG

Rebollo: I just used Area** to create a matrix of Area

therealbeef: nah, just an array of pointers :-)

denis_semen_danil_777: http://chat.codingame.com/pastebin/31164cc7-dbdc-4099-b4ad-0a4136866992

denis_semen_danil_777: :flag_lr:

therealbeef: in c++ it's best to use std::array or std::vector when you need an array. that makes it clearer

denis_semen_danil_777: :pig_nose:

denis_semen_danil_777: :flag_ua:

denis_semen_danil_777: :cherries:

denis_semen_danil_777: :underage:

denis_semen_danil_777: :ok_hand_tone5::point_left:

Default avatar.png BobaAndBiba: Росссия вперед!!!!:muscle_tone1::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::flag_ru::point_up_tone1::pray_tone5:

derjack: where is that cat

Default avatar.png BobaAndBiba: is ban

BlaiseEbuth: He's not working on caturday derjack

Default avatar.png BobaAndBiba: biba

Default avatar.png BobaAndBiba: aboba

Default avatar.png BobaAndBiba: dota 2

Default avatar.png BobaAndBiba: jojo

Default avatar.png Hubertinio: :bow::radioactive::flag_fo:

Uljahn: im here

Default avatar.png BobaAndBiba: щр тщ

Default avatar.png BobaAndBiba: oh no

Default avatar.png BobaAndBiba: help me

Default avatar.png BobaAndBiba: http://chat.codingame.com/pastebin/9424c639-ecdc-41b8-8b04-4db43bd41bf4

Rebollo: I created a array like this

Rebollo: Area** array = new Area*[10];

Rebollo: added this childs (different types)

Rebollo: but still cant acess a propertie

Rebollo: only related to one child

Rebollo: Ball* bb = new Ball(5,5,5); Grass* gg = new Grass();

Rebollo: But can´t reach a propertie of Ball

Rebollo: inside the array

Rebollo: array[0] = bb; array[1] = gg;

Rebollo: A propertie only related to the child

Rebollo: for example Ball->Size

Rebollo: or even distinguish the types

Default avatar.png Streif: р

Default avatar.png Big.Tom: SUIIIIIIIIIIIIIIII

JL727: no

Default avatar.png Hubertinio: SUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

Default avatar.png kobek: hello

Uljahn: no spam guys

Default avatar.png kobek: ok

Default avatar.png kobek: salken

Uljahn: this channel is English-only

derjack: sacre bleu!

Default avatar.png Hubertinio: ola

Default avatar.png Hubertinio: Guten Tag

Fasader: greetings fellow coders

ciscodisco: WAZUUUUUUUUUUUUUUUUUP

Uljahn: you're on thin ice

Default avatar.png HolyCastleFTW_c15a: siema

BlaiseEbuth: Caturday on ice.

5DN1L: Wow, are we reliving Thursday? Many lines in the chat are the same as yesterday's

5DN1L: the spam lines

BlaiseEbuth: Euler Phi Function

5DN1L: :rolling_eyes:

BlaiseEbuth: <3

5DN1L: How many mods have kicked you out so far, BlaiseEbuth? :smirk:

BlaiseEbuth: Hmm... Wonto for joking and euler for a test. :thinking:

Fasader: gotta catch em all?

Fasader: but they're mods, not pokemons

Fasader: smh

Uljahn: why not pokemods?

BlaiseEbuth: :D

Fasader: pocket moderators, hmm

Fasader: would they be pocket sized or would the moderate pockets?

Default avatar.png hardrez: hello everyone

Assasint: Ho is a mother here

5DN1L: Assasint Do you have better things to say? Why don't you solve more puzzles or build some AI bots or play some clashes?

Default avatar.png NgoVu: hi everyone

Default avatar.png NgoVu: today is my birthday but i don't have friends

Default avatar.png HardStoner: again?

Rebollo: the reason is clear

5DN1L: Automaton2000 do you have a botday?

Default avatar.png Automaton2000: in the end you have a sim for this game

Rebollo: Folks, in the console output, c++, by using COUD: Is it possible to use colors?

Rebollo: COUT*

5DN1L: why colors?

Rebollo: just want to show the results graphically withou affecting the data, for better understanding of the behavior

Rebollo: http://chat.codingame.com/pastebin/a471c52f-fbe1-41c6-aa4a-9c890b1abca0

Rebollo: like the colors representing states

Rebollo: or something like that

Rebollo: because let´s say I have 5 states for each char

Rebollo: I would like to see it in a understandable way instead of choosing diferent characters for each state for each character

Rebollo: would result in a huge combination and I will not be able to understand it anymore

Rebollo: cout << "\033[1;31mbold red text\033[0m\n";

Rebollo: trying to use something like that but

struct: yes its possible

struct: but cg doesnt handle it

struct: so its not possible on cg

Rebollo: thanks

Rebollo: is this because of the server type? What the reason? Operational system? Just for curiosity

struct: because its handled as html

struct: or just text I think

Uljahn: might be a unification (and simplification) of the output console to equally support 27 programming languages

Uljahn: also custom colorizing might conflict with dark/light themes or something

Rebollo: nice to know thanks

Uljahn: also colorization works in tech.io snippets

Uljahn: https://tech.io/snippet/RcMYbJo

Rebollo: folks:

Rebollo: In c++ I am able to call a copy contructor while creating a new object

Rebollo: Area* tempArea = ballsVector[ballIndex];

Rebollo: sorry

Rebollo: like this

Rebollo: Area* tempArea(ballsVector[ballIndex]);

Rebollo: but I can´t make it work when I need to assign a existing object to another

Rebollo: like a simple assigment

Rebollo: is it possible to call a copy constructor?

Rebollo: Because when I do the assigment with simple =

Rebollo: I dont want to copy all the properties

Uljahn: do you want to copy/assign a selected set of properties to another object?

therealbeef: what you're assigning in the code you posted is a pointer

Rebollo: I have two nodes, they are in diferent positions of my tree.. I want to swap their references of LEFT and RIGHT

therealbeef: Area a; auto b = a; calls the copy-constructor

Rebollo: Like change the position of the nodes

Rebollo: without changing their data

Rebollo: NodeA->left = NodeB->left

Rebollo: NodeA->right = Nodeb-right

Rebollo: and vice-versa

therealbeef: are left and right pointers to objects? if so, what you wrote would work (though probably needs a tmp variable); it swaps the addresses pointed at

Rebollo: yes they are pointers

Rebollo: Hum I think I got it

Rebollo: but there is something wrong because no matter how distant I go to the right

Rebollo: I never get segmentation error

therealbeef: you think there is a loop?

therealbeef: editing trees can be tricky

Rebollo: At least there is no explicity loop

Rebollo: I just doing like this

Rebollo: http://chat.codingame.com/pastebin/2652c5a5-6375-49c3-b6c1-6c071aa21d3c

Rebollo: I think its poiting to itself somehow

YurkovAS: *sourceObj = *targetObj;

Rebollo: What?

YurkovAS: this work as: auto b = a; calls the copy-constructor

YurkovAS: *b = *a;// for pointers

Rebollo: I am trying I think it is working

Rebollo: 1 more minute

Rebollo: something wrong like a cirsular reference

Rebollo: but could figure out why

Rebollo: circular*

Rebollo: i think it is not calling the copy constructor

Rebollo: I put a cout inside the copy constr

Rebollo: but is not showing in the console..

Rebollo: I did the copy contructor like this

Rebollo: http://chat.codingame.com/pastebin/5b122747-e3cb-4dee-8c88-32e849c9bcae

struct: why are you overwriting the copy constructor?

struct: do you only want to copy certain elements?


Rebollo: Example

Rebollo: I have two Nodes:

Rebollo: A

Rebollo: and B

Rebollo: each one has their own left and right pointers

Rebollo: I want that e B start poiting to the a left and right

Rebollo: and vice versa

Rebollo: At the end I want to swap their places in the data structure

struct: swap the place of a and b?

Rebollo: yes a will point to the b pointers

Rebollo: and b will point to the a pointers

Rebollo: humm

YurkovAS: maybe this is copy assignment

Rebollo: is it possible to swap the memory adress? so I keep track of all the others nodes the were pointing to them?

Rebollo: Because there might exist other nodes the point to them and If I change only their (A e B) reference

Rebollo: this can be a mess

Rebollo: basically

Rebollo: Swap nodes in a linked list without swapping data

struct: well you will have the problem that will still point to the same address

struct: if you swap A with B

struct: everything that was pointing to A will now be poiting to the same address which is B

therealbeef: if you have x - a - y - b - z, remember you will need to edit all 5 nodes

struct: wich has B on it

struct: unless i missunderstood

Rebollo: Yes I think u get the problem

Rebollo: So I need to handle manually

Rebollo: no "smart" way or common used way to solve this problem?

therealbeef: but why not leave a and b in place and just swap their content?

therealbeef: the common way is never to use linked lists ;-)

Rebollo: because they have different types

0xanas: :eyes:

Rebollo: One node is type of ball

Rebollo: the other is grass

Rebollo: There is a parent class commom to them

Rebollo: And in order to access specif properties of the childs

Rebollo: I am doing

Rebollo: http://chat.codingame.com/pastebin/a3efa921-4848-4594-9b1c-3fc50bd8faad

Rebollo: dynamic cast

Rebollo: I though linked list were the best options for graphs

Rebollo: binary trees

Rebollo: fast searches

Rebollo: why not?

Rebollo: but each node hs up, down, left, right

Rebollo: lots of references

therealbeef: well, binary trees are not actually faster than vectors with linear search until you have a million nodes

Rebollo: what about graphs

Rebollo: Where some problems to be solved

Rebollo: I dont need to much data que start getting slow

Rebollo: like Waze

Rebollo: routes

Rebollo: Like a want to visit 100 places

Rebollo: What would be the best track

Rebollo: to save oil for example

Rebollo: I can´t simply test all possibilities

therealbeef: same. problem with linked lists is that they are scattered around memory, so it can't be optimized very well by the cpu

Rebollo: humm

therealbeef: you can represent a graph with a vector too

Rebollo: I really like to swap their values only, but once they are different types

Rebollo: But how would a represent a graph with a vector

Rebollo: without keeping the positions references?

therealbeef: instead of memory addresses you store indices

Rebollo: sorry I don´t want to question your knowledge

Rebollo: is the opposite

Rebollo: I am trying to learning

therealbeef: me too :)

Rebollo: nice

Rebollo: hum like hash?

therealbeef: This is a nice presentation about performance of different data structures in c++: https://youtu.be/fHNmRkzxHWs

therealbeef: from c++ conference

Rebollo: let me have a look

therealbeef: basic message: use vectors unless you have really good reason

Rebollo: it seems it is a common issue

Rebollo: I found lots of references

Rebollo: and like doing only for one pointer like next

Rebollo: is already a big code

Rebollo: At first glace seems simple

Rebollo: I am trying to solve a puzzle which probably doest need that much care about the performance

Rebollo: But I am focused in learning

therealbeef: I think it's good to try different things and learn from them. so making your own linked grid can be very instructional, but you asked for common approach ;)

Rebollo: sure cause I thought I was going to far, wrong way, worst way

Rebollo: I would like to hear some reference

therealbeef: you approach should be possible to make it work, just a bit of headache :)

therealbeef: *your

TimV13-BBG-: it depends on what kind of software you make when it comes to performance. Higher performance usually means less readability.

TimV13-BBG-: try making clean code at first, then look at performance

Rebollo: you are right

TimV13-BBG-: trying to make something run 'fast' can take a lot of time and will cause headaches xD

therealbeef: *cough* data oriented design *cough*

Rebollo: I was watching a sql expert developer that says that he prefers to create a readable code, maintainable to to the detriment of performance for example

Rebollo: of course there are cases and cases

Rebollo: Also he mentioned that you need to avoid comments

Rebollo: The code mmust talk for itself

Rebollo: because sometimes the speak language can be ambiguous or just don´t represent what the code is doing

Rebollo: That´s why I don´t understand ruby, do you?

therealbeef: and functions should be 4 lines at most ;)

Rebollo: I went to a business intelligence pproject for exxon mobil

Rebollo: SAP HANA database

Rebollo: It a in memory data base

Rebollo: I started to create the reporsts

Rebollo: the goal was to run everything live

Rebollo: without materializing the results

Rebollo: I created a generic recursive function

Rebollo: You just need to maintain a table

TimV13-BBG-: never done anything in Ruby but code should indeed speak for itself

Rebollo: to create all the metrics

Rebollo: It turned out that the solution is too hard to maintain

Rebollo: too hard to undertand

Rebollo: And I realized the SQL is a static language

Rebollo: So it would be better to have redundant code

Rebollo: instead of generic things

Rebollo: because once you have some problem

Rebollo: All the solution depends of it

Rebollo: I learned by making this mistaake

Rebollo: never try to do a generic stuff anymore

Rebollo: at least for this kink of language

Rebollo: now I am not in the project anymore

Rebollo: And I wonder how the guys will understand that sutff

Rebollo: :grin:

Rebollo: Once I crashed the server because of this recursive function..no body was able to kill the processes

Rebollo: the were generated in paralell..

therealbeef: code that speaks for itself is a good ideal, but in practice not really maintainable. Imagine a small function in a chain of functions; not always easy to see what it tries to do... but I agree it's something to strive for; at least have descriptive function and variable names

Rebollo: perfect

therealbeef: Interfaces are a different story of course ;)

Rebollo: actually there are some directions / best practices, but there is no wrong or right

Rebollo: lways depends on the scenario

Rebollo: but is awesome to take into account this aspects

Rebollo: Folks

Rebollo: Is it ok to use a Class function inside the contructor?

Rebollo: Like lets say I need to generate a id

Rebollo: And a call a generateIdFunction inside de contructor?

Rebollo: Lets say this function is part of the same class

therealbeef: sure, that's fine. sounds like it would be a static function though (so different instances of the class could have unique ids)

Rebollo: different istances could have unique id? What do you mean? The same ID can be created in different instaces?

Rebollo: or the Opposite?

therealbeef: opposite

Rebollo: I got

Rebollo: yes no problem

therealbeef: static int get_id() { static int id = 0; return id++; }

Rebollo: the ID will make sense only on the instace

Rebollo: I will never compare different instances for example

Ose: 5

Ose: I'm back

Ose: And I can talk!! woohoo! I am no more blocked

jacek: oh my

Ose: what

Uljahn: you'll be blocked again if you don't follow the Code of Conduct

SpaghettiMaster456: CODE of conduct

Ose: oh ok

5DN1L: Well Ose was kicked out by mistake amid chaos yesterday

Uljahn: low level accounts flooding casually are sus

5DN1L: true

Ose: yeah i know that

jacek: oO

Godichou: Hi, I have a question about the exercice "temperatures" in Python, someone did it and is ready to help me? go dm me

IamFish: sent DM

jacek: huh

Nachosauce: You guys are great.

5DN1L: What do you plan to do next, Nachosauce?

5DN1L: Continue with Mad Pod?

5DN1L: Or something else?

Nachosauce: Working on mars lander

Nachosauce: On lunch at work right now, then have meetings through the end of the day :grimacing:

5DN1L: a lot of work :P

5DN1L: Ah I remember you

5DN1L: oops

5DN1L: i mean I remember now

5DN1L: You started Mars Lander 2

5DN1L: but then went back to Mars Lander 1

5DN1L: ah no

Nachosauce: I think I have something flipped somewhere on my landers velocity :sweat_smile: By the time I get to scoring the solution it seems like it might have horizontal and vertical velocity backwards. Ruhroh.

5DN1L: it's somebody else...

5DN1L: haha

5DN1L: easy to fix?

Nachosauce: I sure hope so. Still have to find where/why

5DN1L: ah i see

jacek: so quiet and peaceful

princess_of_zeal: what has changed?

jacek: Automaton2000 changed

Default avatar.png Automaton2000: why would u want to do them all at once

princess_of_zeal: Automaton2000 seems the same spammer as before :-)

Default avatar.png Automaton2000: no, just a few turns

Default avatar.png printMystery: 5

Default avatar.png lonito: who have snap here

5DN1L: https://en.wikipedia.org/wiki/Snap!_(programming_language)

Default avatar.png guylevitsky42: how do I continue after winning Wood 1?

Default avatar.png guylevitsky42: its stuck

5DN1L: Your games are still running

5DN1L: Please wait

5DN1L: Click LAST BATTLES to see the progress of your races being run

5DN1L: You're in Bronze league now

Default avatar.png always0I: some suggestions for beginners to play this

kubus765: depends on what level you are

Rebollo: OMG my steps sre soo small and slow

Rebollo: Every challange I win another think which is suposed to be easy became a nightmare

Rebollo: If you guys can give me a tip

Rebollo: I am trying to sort a vector

Rebollo: of pointers

Rebollo: by the object id propertie

Rebollo: Pointers->Ball->objId

Rebollo: trying this

Rebollo: static bool before( const Pointers& c1, const Pointers& c2 ) { return c1.area->uniqueId < c2.area->uniqueId; }

Rebollo: but I don´t know if I declare that in the Pointer class

Rebollo: or in the ball class

Rebollo: The vector is type Pointer

Rebollo: has child type area

Rebollo: that has child types

Rebollo: ball

Rebollo: grass

Rebollo: water

Rebollo: but all of the childs has a common uniqueId propertie

Rebollo: And I want to sort the aarray by them

Rebollo: uniqueID

ninjadip: a vector of pointers? why not a linked list

ninjadip: which sorting technique are you using

Rebollo: I don´t know the name

Rebollo: but

Rebollo: using this sintaxe

Rebollo: static bool before( const Area& c1, const Area& c2 ) { return c1.uniqueId < c2.uniqueId; }

Rebollo: like a compartions function

Rebollo: I dont know if it is lambda

Rebollo: and calling sort

Rebollo: but once I have a array of Poiters of Areas of Balls

Rebollo: Pointers > Areas > Balls

Rebollo: I don´t know where to declare this comparison function

Rebollo: Class GolfGame

Rebollo: Has an array of Pointers

Rebollo: Which has a pointer to Area

ninjadip: i have more questions then answers, so sorry, i can't help

Rebollo: Which point to Ball

struct: sort(nodes.begin(), nodes.end(), [&](Node* a, Node* b) {return a->visits > b->visits; });

struct: you want something like this?

ninjadip: that looks good

Rebollo: yes

Rebollo: but where do I declare it?

Rebollo: which level?

struct: what do you mean by level?

Rebollo: I have 4 classes

Rebollo: GolfGame has

Rebollo: a array of POinter

Rebollo: that has

Rebollo: a pointer to Area

Rebollo: That has childs of many types

Rebollo: but all the child types has a uniqueId in common

Rebollo: And I want to sort the a array of POinter by the uniqueId

Rebollo: of their lowest level in the hierarchy

struct: well I guess you either store in area the lowest unique id yet

Rebollo: Class 1 has a vector of Class2 of type Class 3 which has objects of Class4

struct: or you loop them when you sort

struct: which wont be as efficient

Rebollo: Its pretty small data set

Rebollo: I wa trying to use this approch

Rebollo: sort(nodes.begin(), nodes.end(), [&](Node* a, Node* b) {return a->visits > b->visits; });


Rebollo: But in my scenario

Rebollo: in which level should I declare this guy?

Rebollo: I am getting this error

Rebollo: #include <algorithm>


struct: you need algorithm for sort

Rebollo: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, http://chat.codingame.com/pastebin/929a6a19-ec05-4567-9451-3e4cd1019b57

Rebollo: Like manually?

struct: I think this is your error

struct: error: invalid initialization of reference of type ‘const Area&’ from expression of type ‘Pointers*’

struct: Can you pate your sort here?

struct: paste*

Rebollo: I don´t have a sort function..I think that using this guy:


Rebollo: static bool before( const Area& c1, const Area& c2 ) { return c1.uniqueId < c2.uniqueId; }

Rebollo: I just need to call sort begin... etc

Rebollo: std::sort

Rebollo: trying to follow this stack overflow code

Rebollo: http://chat.codingame.com/pastebin/b5192f0d-165e-4b71-a635-d1bb4d5e8ab5

struct: doesnt the first sort work?

struct: which one is throwing the error?

struct: the 2nd or 1st'


Rebollo: hum I think it worked

Rebollo: http://chat.codingame.com/pastebin/afe2db6a-0e63-44e5-9592-32ec843b2e48

Rebollo: I use * instead of &

Rebollo: like u said

Rebollo: But in stack is using &

Rebollo: worked

Rebollo: NICEEEE

Rebollo: :grinning:

Rebollo: uhulll

Rebollo: thank you guys

Rebollo: this platform is amazing

Rebollo: Like some of your questions and tips open my mind a lot

Rebollo: now I will implement this guy

Rebollo: returnStringOfPossibleWaysToGoForEveryBallIndenpendenTly

Rebollo: :stuck_out_tongue_closed_eyes:

Rebollo: I still dont understand the pointers

Rebollo: sometimes use *

Rebollo: sometimes &

Rebollo: sometimes new

Rebollo: sometimes it overwrite the copy

Rebollo: sometime don´t

Rebollo: like the IDE quick fixes kind of perform a lot of work to me

Rebollo: in this aspect

struct: Which part dont you understand?

Manchi_o6o7: Hey guys. Can someone maybe help me out with some tips where to start and how to start learning about machine learning in C++

Rebollo: Like, when I am using a custom type, a class such as Ball..I alway create like basic types without pointer

Rebollo: And custom type as pointer

Rebollo: when I create a pointer

Rebollo: It is necessarily a vector?

Rebollo: When I need to instantiate with new

Rebollo: And when don´t

Rebollo: A vector is always apointer?

Rebollo: A matrix is two pointers?

ninjadip: two-dimensial array

Rebollo: but internally

Rebollo: it is a pointer?

Rebollo: Why sometime a * is interpreted sa pointer

Rebollo: and sometime as array?

ninjadip: yay i finally landed this mf*?! mars lander

5DN1L: :clap: ninjadip

Rebollo: :heart_eyes:

ninjadip: lol

ninjadip: sorry, was stressful, they just kept dying... over and over

Rebollo: Best sensation

struct: so you have pointers inside the Ball?

struct: this is not always needed depends on what you are doing

Rebollo: I have a class called Game is like the engine of everything

Rebollo: The class called Game

Rebollo: Has an array of pointer (I created this level to ecapsulated the different child objects)

Rebollo: The pointer has a pointer os Parent

Rebollo: which has pointers of balls

Rebollo: grass

Rebollo: water

Rebollo: hole

Rebollo: Game>Pointers of Parent > Parent > Balls/Holes/Grass

Rebollo: The only way I could ass different type in same data scructure

Rebollo: add*

Manchi_o6o7: *arr = new int[10]; you make basically 10 spots in the memory or 40 bytes to store your values. arr is holding the first value and when you for example type arr[4] it means that you want the element which is 16 bytes from the starting element in the array

Manchi_o6o7: if this makes sense to you

Rebollo: YES

Rebollo: nice

Rebollo: what if i do like this?

Rebollo: int *a = 10;

Rebollo: it is 16 bytes only

struct: that doesnt work

Rebollo: what about

Rebollo: Ball *b = new Ball()

struct: int* a = new int(10); cerr << a << endl; cerr << *a << endl;

struct: will print address then print 10

struct: Ball *b = new Ball() works yes

struct: Ball a = Ball(); Ball *b = &a;

struct: and b will point to a

struct: everything will change either on b or a will affect both

struct: since its pointing to the address of a

Rebollo: Why would I need to create another then

Rebollo: if is exaclty the same

Rebollo: Ball a = Ball();

Rebollo: Now I want ot create a copy of a

Rebollo: not a reference

struct: because it wont copy

struct: it will save the reference

Rebollo: and if I need to copy?

Rebollo: to create to separated object that the change wont affect each other

struct: Ball *b = new Ball(a);

struct: it will copy it

Rebollo: I have to create a special contructor for this?

Manchi_o6o7: this is a copy constructor

struct: no

struct: maybe if you have pointers inside of what you are copying, im not sure

Manchi_o6o7: It depends if you need to make a deep copy

Rebollo: ok

Rebollo: why u have to use * in this case

Rebollo: Ball *b = new Ball(a);

Rebollo: And the argument must be a pointer?

Rebollo: a argument

Rebollo: "a"

Manchi_o6o7: it can also be Ball b=*a;

struct: because of new

Manchi_o6o7: but it depends what you want from the "b"

struct: it will store on the heap

struct: You can also do

struct: Ball b = a;

struct: but it will be stored on the stack

Rebollo: I have to check what is heap and stack but I will take it a homework

Rebollo: dont worry

Default avatar.png Notter2: Hi

Manchi_o6o7: try to learn from the basics

Manchi_o6o7: Then everything will be easier

struct: https://tech.io/snippet/BAKKhfO

struct: hi

Default avatar.png Notter2: Why can't I access CoC chats?

Rebollo: When I use struct and when I use class?

Rebollo: I see a lot of sample using struct

Manchi_o6o7: Struct is more a C thing. In C++ you use classes.

Manchi_o6o7: The default privacy in a struct is public, while in a class it is private

Rebollo: cool

Rebollo: I have seen guys instatiating pointers with void type

Rebollo: but couldn´t use

Manchi_o6o7: You can use a struct for example if you want to make a struct for a node inside a graph class

Rebollo: And the same concept of pointers and etc?

struct: pointer is the same thing as a class

struct: but class is private by default and struct is public

Rebollo: I see

GBDev13: hi!

struct: hi

struct: i didnt meant pointer, i meant struct :p

Default avatar.png WalkersApple: When the booleans are sus: :P

Default avatar.png FORMS1: Did anyone find a way to do the ASCII Art puzzle without manually assigning each letter?

Husoski: FORMS1 Huh? The raster map is given at the end of the input. There's no need to "manually" do anything. Just read it in and organize it. What sort of "manually" did you have in mind?

Rebollo: Guys, everytime I need to get a single character from a string like this stringSample[0], it necessarily return a char?

Husoski: I did manually type in the string version of the characters, 'ABCD...XYZ?', but that was easier than, generating the range from ord('A') to ord ('z') and tacking on a ? at the end.[*range(65,91),

Rebollo: It alway a mess to convert to String again

Rebollo: if is a number return wrong results

Husoski: Rebollo what language?

Rebollo: c++

Rebollo: I hate char

Rebollo: :yum:

Husoski: yes, it's a char in C++

Rebollo: ok, how can I converto to a string wihthout messing yhe value

Rebollo: like if it is a number

Rebollo: '5'

Rebollo: and I use

Rebollo: std::to_string

Rebollo: I got the wrong result

Husoski: ...checking cppreference...

struct: so you wan to convert '5' to 5?

Rebollo: to "5"

Rebollo: char to string

Rebollo: to_string got different value

Thorcode: what the difference between "5" and '5'

struct: str += '5';

struct: should work fine

Husoski: you can use std::string(1,c) to make a single character string.

Rebollo: thankl you guys

Husoski: .,.or string(42,c) to make 42 copies of c in a single string

Rebollo: nice to know

Rebollo: thanks

ninjadip: EFF YEAH 100% on mars lander level 2

Husoski: struct good call. I'd forgotten that string::operator+ can take a char.

Rebollo: Is that one nice Nija?

ninjadip: now i can go do my actual homework that i've been avoiding

Rebollo: Which concepts to learn?

ninjadip: this was a pain in the but

Rebollo: lol

ninjadip: one trig function to figure angle

Rebollo: trigonometry?

ninjadip: it says i learned distances and trig

Husoski: Lots of physics in Mars Landers

ninjadip: lots

Rebollo: nice

ninjadip: but very cool to me cause i love space

ninjadip: let's see, under 200 lines of code, c++. so not terrible. just a lot of conditions

Rebollo: Have you seen a actual rocket landing back on earth exaclty in the target? I think few months ago?

ninjadip: for all the physics factoring

ninjadip: if i'm going this fast but want to go to this way.. is a mountain coming up, do i have to wait to steer just to stay up? blah blah blah

ninjadip: ok later everyone

ninjadip: oh, i've seen some spaceX landings

ninjadip: failed and succesful

ninjadip: interesting

Rebollo: yes but, there is no try and error

Rebollo: you have one chance

Rebollo: of course there are powerfull simulators but

Rebollo: unimaginable the mind of this guys

Default avatar.png Rodrigo_the_coder: help