Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe20.iad.POSTED!7564ea0f!not-for-mail
From: Doug Schwarz <see@sig.for.address.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: problem in calling show function in Object oriented
References: <hb5nb0$s06$1@fred.mathworks.com> <see-16B817.20104414102009@news.frontiernet.net> <hb5slj$33i$1@fred.mathworks.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X)
Message-ID: <see-9735E1.22521314102009@news.frontiernet.net>
Lines: 93
X-Complaints-To: abuse-news@frontiernet.net
NNTP-Posting-Date: Thu, 15 Oct 2009 02:52:14 UTC
Organization: Frontier
Date: Wed, 14 Oct 2009 22:52:13 -0400
Xref: news.mathworks.com comp.soft-sys.matlab:577400


[top posting repaired]

In article <hb5slj$33i$1@fred.mathworks.com>,
 "Syed " <cancer216@hotmail.com> wrote:

> Doug Schwarz <see@sig.for.address.edu> wrote in message 
> <see-16B817.20104414102009@news.frontiernet.net>...
> > In article <hb5nb0$s06$1@fred.mathworks.com>,
> >  "Syed " <cancer216@hotmail.com> wrote:
> > 
> > > classdef points
> > >     properties
> > >         x
> > >         y
> > >     end
> > >     methods
> > >         function pp= point(x,y)
> > >             this.x=x;
> > >             this.y=y;
> > >         end
> > >         function show()
> > >             disp('hhehe');
> > >         end
> > >     end
> > > end
> > 
> > 
> > Try something like this:
> > 
> > 
> > classdef points
> >     properties
> >         x
> >         y
> >     end
> >     methods
> >         function this = point(x,y)
> >             this.x = x;
> >             this.y = y;
> >         end
> >         function show(this)
> >             disp('hhehe');
> >         end
> >     end
> > end
> > 
> > 
> > By comparing my code with your code it should be obvious what you did 
> > wrong.
>
> Yes I found the error  this = point(x,y) but still same error ??? No 
> appropriate method or public field show for class point. Now I think I am 
> having problem calling class functions on object of the class. Kindly try to 
> run the code and suggest me something to fix this problem. 
> classdef point
>     properties
>         x
>         y
>     end
>     methods
>         function this= point(x,y)
>             this.x=x;
>             this.y=y;
>         end
>         function this.show()
>             this.disp('something');
>         end
>         function this.xchange(var)
>             this.x=var;
>         end
>     end
> end

Please don't top post.

You didn't read my code carefully enough.  You must pass the object into 
show() even though you don't use the object inside this simple example 
method.

    function show(this)
        disp('hhehe');
    end

Similarly, xchange should be

    function this = xchange(this,var)
        this.x = var;
    end

-- 
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.