User Profile

Collapse

Profile Sidebar

Collapse
vinothg
vinothg
Last Activity: Sep 10 '08, 02:14 PM
Joined: Oct 24 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • vinothg
    replied to class design
    in C
    Nice one !!!

    #include <iostream>

    using namespace std;

    class foo{
    public:
    foo& operator () (){
    return *this;
    }
    };

    int main(){
    foo()()()()()() ()()();
    getchar();
    ...
    See more | Go to post

    Leave a comment:


  • vinothg
    started a topic printf question
    in C

    printf question

    Hi,

    Check this program.

    #include <stdio.h>

    int main()
    {
    int x = 0xFFFFFFF0;
    printf("%X\n",x );
    char y = x;
    printf("%X\n", y);
    getchar();
    }


    I have FFFFFFF0 in int variable x and i am assigning it to char. Since a char can hold only 8 bits, it should have only F0. But when i try to print it, it prints the entire...
    See more | Go to post

  • vinothg
    replied to How do i convert a char to int?
    in Java
    I showed this as an example. If i put this is a function which accepts an int and use that paramter in place of 1100 it will be generic.
    See more | Go to post

    Leave a comment:


  • vinothg
    replied to How do i convert a char to int?
    in Java
    How about this ...

    String s = "" + 1110;
    int[] b = new int[4];
    for(int i=0; i<s.length();i+ +) {
    int d =Integer.parseI nt(""+ s.charAt(i));
    b[i]=d;
    }
    See more | Go to post

    Leave a comment:


  • vinothg
    started a topic Private Interface example
    in Java

    Private Interface example

    Just thought of posting this example about private interface which i learned from bruce eckel book "Thinking in Java"

    An interface can be nested within a class or another interface. If the interface is nested within a class it can be public or private. But if a interface is nested within a interface it should be public which is by rule.

    I was wondering what will be the use of private interface within a class....
    See more | Go to post

  • vinothg
    replied to C++ constructor differs from java
    in C
    Is it because "this" is a reference to the object in java and "this" is a pointer in c++
    See more | Go to post

    Leave a comment:


  • vinothg
    started a topic C++ constructor differs from java
    in C

    C++ constructor differs from java

    Hi,

    I was just browsing some java code and found that it is possible in java to call a constructor within another constructor. The rule being that the it should be first line in the constructor and also there shouldn't be any duplication.Bot h these rules have valid reasons. But why can't we do the same in c++.

    Java Code :

    public class c {

    public c(){}
    public c(int a){
    ...
    See more | Go to post

  • vinothg
    replied to Java code for auto answer
    in Java
    Yes you are correct. I have a InputStream and OutputStream. I know it is unfair to ask more than this. I have an inputStream which displays what happens on the remote machine i.e it shows the script running status. Any idea on how to grep for a particular statement. Just a clue on which function to use. In the mean time let me go through the API ...

    Thanks for your quick reply.
    See more | Go to post

    Leave a comment:


  • vinothg
    started a topic Java code for auto answer
    in Java

    Java code for auto answer

    Hi ,

    I am new to java and i created a program which does an automatic SSH connection from host to a remote machine. I have created a channel from host to remote machine and i am executing certain scripts in the remote machine from the host. This has been done in java. Now the problem is when i run some scripts it prompts for Y/N type of question. I need to answer to that from host machine. Is there anyway to do this.
    ...
    See more | Go to post

  • vinothg
    replied to Inheritance Doubt
    in Java
    I am sorry as i recalled now that all methods in java defaults to virtual. In C++, it needs to be done explicitly.
    See more | Go to post

    Leave a comment:


  • vinothg
    started a topic Inheritance Doubt
    in Java

    Inheritance Doubt

    Hi ,

    I am migrating slowly from c++ to java. The output of the following program differs from c++ in java. It should be really easy for any java programmer to explain. Just an hint could help me to understand.


    class base {
    public void f(){
    System.out.prin tln("base.f()") ;
    g();
    }
    public void g(){
    System.out.prin tln("base.g()") ;
    }
    }...
    See more | Go to post

  • How compiler diffrentiates oridnary/member funtion w.r.t private data members

    Hi All,

    I just wanna know how compiler diffrentiates between a ordinary function and member function. I know that compiler will secretly pass the this pointer to member functions. Eg : look at this code.
    [code=cpp]
    #include <iostream>

    using namespace std;

    class A {
    int i;
    public :
    int k;
    void set(A* a, int i){
    a -> i = i; >>>> Here it...
    See more | Go to post
    Last edited by sicarie; Sep 20 '07, 01:03 PM. Reason: Code tags

  • Accessing private data members from ordinary function and member function

    Guys,

    I just wanna know how compiler diffrentiates between a ordinary function and member function. I know that compiler will secretly pass the this pointer to member functions. Eg : look at this code.

    #include <iostream>

    using namespace std;

    class A {
    int i;
    public :
    int k;
    void set(A* a, int i){
    a -> i = i; ...
    See more | Go to post

  • You have a static variable as a data member in your class.Static variables will not be initalized by the constructor.It has to be explicitly define it.

    You need to add this line.
    HotDogStand::To talSales = 0;

    If you still have queries refer
    http://www.parashift.c om/c++-faq-lite/ctors.html#faq-10.10
    See more | Go to post

    Leave a comment:


  • vinothg
    started a topic Silly Pointer Problem
    in C

    Silly Pointer Problem

    Hi ,

    I just wanna know why such a wierd output is seen for the following program.I know it is pretty simple but i can't make it.Just a clue could help me to sort out the issue.

    Code:
    #include <iostream.h>
    #include <stdio.h>
    
    void func(char *s)
    {
       printf("%x \n",s);
       s="senthil";
       printf("%s %x\n",s,s);
    }
    ...
    See more | Go to post

  • vinothg
    started a topic Read/write problem using fstream in binary mode.
    in C

    Read/write problem using fstream in binary mode.

    I have a binary file,which contains strings of 30 bytes each.I need to open the file,read the strings one by one and if the string is not found i need to write it.But unfortunately both read and write using fstream is not not working.If i close the file and open it again it works.

    Code:
    #include <iostream>
    #include <sys/stat.h>
    #include <fstream>
    
    int main(){
    fstream fs;
    ...
    See more | Go to post
    Last edited by Banfa; Nov 1 '06, 12:54 PM. Reason: Added [code]...[/code] round the code

  • vinothg
    replied to Array problem
    in C
    You can use Associative array i.e STL containers for this problem.

    The best container for this would be the SET container.
    See more | Go to post

    Leave a comment:


  • vinothg
    replied to Opening a file as binary and editing it
    in C
    Ok if you know the exact offset where you want to append then this piece of code may help you.

    #include <iostream>
    #include <fstream>
    using namespace std;

    int main(){
    ofstream os("test",ios:: out|ios::app|io s::binary);
    os.seekg(20,ios ::beg);
    char buffer[3] = {"Hi"}
    os.write((char* )(&buffer),size of(buffer));
    os.close();
    }
    See more | Go to post

    Leave a comment:


  • vinothg
    replied to Rogue wave
    in C
    When you create a object for the Dlist it certainly occupies the memory.

    If i recall correctly the correct procedure to avoid memory leaks when using a Dlist is :

    Delete the element with a pointer list and at the end, delete all the elements and the list with clearAndDestory
    See more | Go to post

    Leave a comment:


  • vinothg
    replied to Opening a file as binary and editing it
    in C
    When you open the binary file add ios::ate so that the string will get appended instead of overwriting i.e

    nfile.open("new .txt",ios::in|i os::out|ios::at e|ios::binary);

    Hope it will work !!!
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...