• Member Avatar for sepp2k
    sepp2k

    Began Watching Constructors/Destuctors

    Hi all! I'm having some trouble with constructors and destructors. I've been told that a constructor creates an object and a destructor destroys it. The problem is that in my …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Constructors/Destuctors

    A destructor is called (automatically) when an object is destroyed. It does not itself destroy the object. An object is destroyed when it goes out of scope or when `delete` …
  • Member Avatar for sepp2k
    sepp2k

    Gave Reputation to Moschops in multiple definition of function

    `#include "action.cpp"` This tells the preprocessor to paste the contents of the text file "action.cpp" into this position, just as if you had yourself manually typed it in at that …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching multiple definition of function

    Here is my code: #include <string> extern std::string commands[]; extern std::string shortcuts[]; int in_array(std::string ar[], std::string txt){ for(int i=0;i<ar->size();i++){ int g=ar->compare(txt); if(!g){ return i; } } return -1; } int …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in multiple definition of function

    Can you show us the other files (or rather a minimal version of them that still produces the same error message) in the project and how you build the project?
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Goto trouble

    Use a while loop.
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Goto trouble

    So I just started using the Goto command and I have some trouble with it. I will post my code and explain the problem. cout<<"So here we are at your …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Goto trouble

    > So I just started using the Goto command Perfect time to stop. > But when I type in follow or Follow it gives me the text that I intend …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Declare vector with size

    You can't call constructors in the class body. You have to do it in the initializer list of your class's constructor. Like so: class Activity : public Event { private: …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Declare vector with size

    I'm new to using vectors, and I'm trying to declare a vector with size 1: vector<string> activities(1); I get an error with this code, can anyone explain why? G:\ManageActivities\Activity.h|11|error: expected …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Declare vector with size

    Can you show a complete code sample that causes that error? That line looks fine on its own.
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Including C++ files

    Is it poor convention to create a c++ file only to store various functions, and then include it into the main.cpp? This would be done so that the functions could …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Including C++ files

    You don't link individual functions - you link files. If all your files are added to the same project, the compiler (or rather the linker) will link all your files …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Do while NOT

    Hi guys so I am still learning and there might be an easier way to do thing than how i do them but still i need some help. So I …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Do while NOT

    > So how do I do the do while NOT thing `while(!thing)` > Perhaps a switch -- case statement will do the trick here. You can't switch on strings. And …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Warning [2054] suspicious pointer conversion

    #include <p18F8680.h> #include <delays.h> #include <string.h> #include <stdio.h> #include "LCD_Utilities.h" int* lpc_L1; unsigned int ln_Volts; unsigned int ln_Tenths; unsigned char luc_Result; char Convert_ADCResult_to_Char(unsigned char, unsigned char); void main (void) { …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Warning [2054] suspicious pointer conversion

    Why are you trying to cast a string to an int pointer on that line? That is indeed suspicious.
  • Member Avatar for sepp2k
    sepp2k

    Began Watching C++ Backspace or Delete

    Hi Guys, I'm a beginner. Can i ask, how to write the code for delete or backspac in a password if i key in a wrongly? Example: Password is 123456 …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in C++ Backspace or Delete

    You mean, you wrote a program that's asking for a password and using the backspace and delete keys does not work in that program (or at least doesn't work when …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching execution time

    An algorithm takes 1 second to execute for an input size of 10. What will the largest size of input be that can be executed in 25 seconds if the …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in execution time

    If the running time is equal to `n^2 u` for some unit `u`, then you can easily solve for `u` in `10^2 u = 1 second` and then insert the …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Vector

    #include "stdafx.h" #include<vector> #include<iostream> using namespace std; int main( int argc, char ** argv ) { // from initializer list (C++11) cout << "vector from initializer list (C++11): " << …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Vector

    According to [this list](http://msdn.microsoft.com/en-us/library/hh567368.aspx) Visual Studio did not support initializer lists until version 2013. So you just won't be able to use this feature with your version of Visual Studio.
  • Member Avatar for sepp2k
    sepp2k

    Began Watching String Literal

    #include<stdio.h> int main(int argc, char *argv[]) { char *states[] = { "California", "Oregon", "Washington", "Texas" }; printf("size of states: %d",sizeof(states)); return 0; } the result of this is: size of …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in String Literal

    `sizeof(states)` gives you the number of bytes in the array. The number of bytes in an array equals the number of elements times the number of bytes per element. The …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching pointers and refs

    In the following program I'm getting the warning -> unused variable ‘fn’. I'm following along with a book so I don't know why it gave me that portion of code …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in pointers and refs

    > I don't know why it gave me that portion of code if it's unusable `fn` is *unused*, not *unusable*. You could replace line 19 with `fn(rNum, ptr)` and thus …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Applet Confusion

    That's not really true. The compiler will know whether you're using `java.awt.Color` regardless of whether or not you use an import. All the import does is to allow you to …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Applet Confusion

    What's the relation between a class that has a main method and the String class? The relation is that there's a method that takes an instance of that class as …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Applet Confusion

    first se these methods setForeground(Color.cyan); setBackground(Color.red); these methods are defined in Component class like this java.awt.Component and we pass parameters of an other class this is very confusable for me …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Applet Confusion

    Are you asking why a method defined in Component can take a Color as its argument? Why wouldn't it be able to? It is perfectly common for methods to take …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in How does linking occur in this?

    If you hadn't included functions.h in Main.cpp, you'd have gotten a compilation error telling you that `print_hello` and `factorial` were undeclared.
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Who call Applets methods

    JApplet extends Component.
  • Member Avatar for sepp2k
    sepp2k

    Began Watching How does linking occur in this?

    Main.cpp #include <iostream.h> #include "functions.h" int main(){ print_hello(); cout << endl; cout << "The factorial of 5 is " << factorial(5) << endl; return 0; } hello.cpp #include <iostream.h> #include …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in How does linking occur in this?

    The purpose of the header files is to provide declarations for the functions, so that the compiler knows what their types are. This is necessary for the compiler to properly …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Who call Applets methods

    The current object is the object that the method is being called on, that is the object referred to by `this`. > we are not creating any object of any …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in length declared as a reference but not initialized

    `int& length = 0;` does not work because 0 is not an l-value. As I said an l-value is something like a variable or an array access - something that …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Who call Applets methods

    i am very confuse about java applets so please solve my questions my question is that when we write applet then we write only methods defination not method calling so …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Who call Applets methods

    > my question is that when we write applet then we write only methods defination not method calling so i am confuse about this that who call the methods of …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching length declared as a reference but not initialized

    It's giving me an error telling me my reference variable hasn't been initialized. What does that mean, what's wrong with my code here? /* ------ FUNCTION: NEW ENTRY ------------------------------------ ----------------------------------------------------------------*/ …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in length declared as a reference but not initialized

    As the message says `int& length` is a reference (that's what the `&` means). You can not define a reference without initializing it. That is you need to do `int& …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in C array problem

    > It still has a value That's not necessarily true: An uninitialized local variable may contain a trap representation for its type (and thus not a valid value), in which …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching C array problem

    Hi! I'm a student learning C language. During my exercise I have faced a weird problem(atleast to me). I have encountered two declarations: int size; int arr[size]; I'm unable to …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in C array problem

    Your first piece of code is illegal. In C89 it's illegal because array sizes need to be compile-time constants, so variables are not allowed. A conforming compile should give an …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Formatting a string

    Yes, because `secs` is the third argument and `hrs` is the first. You can use either `MyTime(0, 0, totalsec)` or `MyTime(secs = totalsec)`.
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Formatting a string

    I wanted to format this string but I don't know how I can do the formatting part at all. class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Formatting a string

    If you do `print(t1)`, you'll use the `__str__` method that you defined. The reason that it's not being called when you do `print(t1.increment(300))` is that `increment` returns an integer, not …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Command Interpreter using C

    Wait, do you want to create your own command line program that you start from the command line and into which you can then enter the command "display bla.txt" (which …
  • Member Avatar for sepp2k
    sepp2k

    Began Watching Tuple error

    This is my code: class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes = mins self.seconds = secs if self.seconds >= 60: self.minutes += self.seconds // 60 self.seconds …
  • Member Avatar for sepp2k
    sepp2k

    Replied To a Post in Tuple error

    As the error message says, tuples don't have a `between` method, so you can't do `t.between(...)` where `t` is a tuple. You can call `between` on `MyTime` objects because you …

The End.