 Anonymous
    Anonymous 
    
    
        
        
        
        #include <stdio.h>
         
        int main()
        {
          int n, c, k, space = 1;
         
          printf("Enter number of rows\n");
          scanf("%d", &n);
         
          space = n - 1;
         
          for (k = 1; k <= n; k++)
          {
            for (c = 1; c <= space; c++)
              printf(" ");
         
            space--;
         
            for (c = 1; c <= 2*k-1; c++)
              printf("*");
         
            printf("\n");
          }
         
          space = 1;
         
          for (k = 1; k <= n - 1; k++)
          {
            for (c = 1; c <= space; c++)
              printf(" ");
         
            space++;
         
            for (c = 1 ; c <= 2*(n-k)-1; c++)
              printf("*");
         
            printf("\n");
          }
         
          return 0;
        }
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Any simplification to reduce code
    
 
     Liam
    Liam 
    
    
        
                    
                        
                            
                            What you mean? First is call the A constructor everytime i know
                        
                    
                
        
        
        In A b = B();, C++ will:
        
        1. call the explicitly called default constructor of B,
        2. call the copy constructor of A, say A::A(const A&).
        
        In the process of 2, the object of B, which is constructed in 1, is passed as the parameter to A::A(const A&) and then, everything declared in B but not in A will be dropped. Since b is an object of the base class A, and does not have enough space to hold all elements of the derived class B.
    
 
 
     Liam
    Liam 
    
    
        
        
        
        B() creates a temp object of the class B, and then passed to the copy cosntructor of A. After the copy constructor is called, the temp object will then be destructed.
        
        Please kindly note that, b is an object of the base class A, rather than a pointer or a reference.
    
 
     Liam
    Liam 
    
    
        
        
        
        https://stackoverflow.com/questions/274626/what-is-object-slicing
        
        FYI.
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        https://stackoverflow.com/
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Super developer site
    
 
     Liam
    Liam 
    
    
        
        
        
        #include <iostream>
        
        class Base {
         public:
            Base() : foo{0} {
                std::cout << "Default constructor of 'Base' is called." << std::endl;
            }
            Base(const Base& orig) : foo{orig.foo} {
                std::cout << "Copy constructor of 'Base' is called." << std::endl;
            }
            Base& operator=(Base& orig) {
                std::cout << "Copy assignment of 'Base' is called." << std::endl;
                this->foo = orig.foo;
                return *this;
            }
            virtual ~Base() {}
        
         private:
            size_t foo = 0;
        };
        
        class Derived : public Base {
         public:
            Derived() : Base(), bar{0} {
                std::cout << "Default constructor of 'Derived' is called." << std::endl;
            }
        
         private:
            size_t bar = 0;
        };
        
        int main() {
            Base derived = Derived();
            return 0;
        }
        
        Gives the following result:
    
 
     Liam
    Liam 
    
    
 
     Francesco
    Francesco 
    
    
        
        
        
        @LiamHuang Thx m8
    
 
     Liam
    Liam 
    
    
        
        
        
        In this snippet of code, derived is an object of the Base class, and hence has no member data named bar. However, calling Derived() creates a temp object of Derived, which, of course, has a member data named bar. In the copy constructor of Base, bar in the temp object of Derived is dropped. And we called this crop or slice.
    
 
     Liam
    Liam 
    
    
        
                    
                        
                            
                            Any simplification to reduce code
                        
                    
                
        
        
        Since this looks like a homework, I'll not give you the answer directly. However, I have a more complex version of the plotting code. 
        
        #include <stdio.h>
        
        const int w = 23;
        const int h = 12;
        
        int triangle(int x, int y) {
            return abs(x) <= y;
        }
        
        int f(int x, int y) {
            return triangle(x - 11, y) &&
                   triangle((x + y / 3 * 3 + 3) % 6 - 2, y % 3);
        }
        
        int main() {
             int x, y;
             for (y = 0; y < h; y++) {
                 for (x = 0; x < w; x++)
                     printf(f(x, y) ? "* " : "  ");
                 puts("");
             }
        }
        
        Enjoy.
    
 
 
     Liam
    Liam 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        hey guys
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        c++ how game?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        how to make game 3d?
    
 
     Isc
    Isc 
    
    
        
        
        
        opengl
    
 
     Francesco
    Francesco 
    
    
        
                    
                        
                            
                            c++ how game?
                        
                    
                
        
        
        Unreal if you want a game engine. You can do also with sfml (and opengl as already suggest)
    
 
 
     Liam
    Liam 
    
    
        
        
        
        Hmmm, if you have enough basic mathematics knowledge, You could draw static 3D figures by pure C/C++ codes.
    
 
     Liam
    Liam 
    
    
 
     Liam
    Liam 
    
    
        
        
        
        For example, I draw this figure by pure C codes.
        
        (light refraction in a glass M shape)
    
 
     Liam
    Liam 
    
    
        
        
        
        lol
    
 
     Liam
    Liam 
    
    
        
        
        
        However, for game programming, a game engine is required.
    
 
     Francesco
    Francesco 
    
    
 
     Liam
    Liam 
    
    
        
                    
                        
                            
                            Opengl?
                        
                    
                
        
        
        Nope, just math.h, stdlib.h, some mathematics calculation and of course a plotting library (just for saving figures).
    
 
 
     Francesco
    Francesco 
    
    
        
        
        
        Ah, cool
    
 
     Francesco
    Francesco 
    
    
        
        
        
        How much time take to create this image?
    
 
     Liam
    Liam 
    
    
        
        
        
        I don't know...
        
        It's a secondary product of a major project.
    
 
     Liam
    Liam 
    
    
        
        
        
        Hard to estimate...
    
 
     Liam
    Liam 
    
    
        
        
                    
                
        
        lower the sample number. (Monte Carlo integration)
    
 
 
     AndrEEa
    AndrEEa 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        who can help me
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        please
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        in c programming enter n and show this number n power or not  of 3 and which power without multyple and devide ways only if else and for
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        please
    
 
     AndrEEa
    AndrEEa 
    
    
        
        
        
        nope
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        please
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        help me
    
 
     Anonymous
    Anonymous 
    
    
 
     AndrEEa
    AndrEEa 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Hello guys
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        do you have hack channels
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        premium account?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Hi there
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        I really really want to learn programming language 
        But unfortunately there is no course or any center in my town to learn 
        Can you tell me where to start plz
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        lemme find a good beginner book on c++ for ya
    
 
     k1k3
    k1k3 
    
    
        
        
        
        hi
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        also, before starting ( i assume you are on windows ) install visual studio 17
        
        https://youtu.be/39IsItNIoQs
        
        follow this video until it installed
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        if you need help write your problem here or just pm me
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
 
     Max
    Max 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Also guys, if you need a book just ask and i will send it
    
 
     Григорий
    Григорий 
    
    
        
        
        
        Hello, guys. 
        Is anyone working on MacBook in Sublime? Could you say how to compile my code there?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        I have one year left before  graduation..AT THE end of 2018 i am supposed to make a mobile application as a graduation project..will i be able to learn  java in summer?
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        and already knowing c++ is really helpfull
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Thank u
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        😌
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        one thing different is the input, you need to manually cast a string
        ex.
        
        int x = Integer.parseInt(s);
        // needs to be in a try catch or 
        // need to throw IOException
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        the rest is similar to c++, output is made with a function within an object within a Class (System.out.println if you wanna go new line at the end or System.out.print if you dont want to)
        
        if, while, do while, for and switch case are the same as c++
        
        variables are almost equals (except boolean instead of bool and arrays are defined a bit differently)
        
        main in a method (function) inside a class
        
        classes have same idea but a bit different syntax,for example.you have to tell each attribute and method if it's public, protected or private and methods are defined within the class after the prototype
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        and everything has to be within a class
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        this is a sum up of what to expect with java
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        and in methods if you parse a primitive variable its parsed by value, and an object or array by reference
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        objects and arrays (arrays are objects) are parsed by reference
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        try modifying an external object within a method
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        it modifies it
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        strange, with me it worked parse by reference
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        https://www.google.it/url?sa=t&source=web&rct=j&url=https://www.javaworld.com/article/2077424/learn-java/does-java-pass-by-reference-or-pass-by-value.amp.html&ved=0ahUKEwiQueDbmfbXAhVEXBoKHSwtAJ0QFgg4MAM&usg=AOvVaw2lU7FetN_b1451EFANOMwo&cf=1
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        in fact
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        it copies the reference