www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Need help in templates

reply Ishan Thilina <ishanthilina gmail.com> writes:
Hi,

I'm still new to D. I tried to implement a stack using templates. But I get an
"Access Violation" error when I try to run a test on the stack that I made.The
source code is attached with this mail. Can somebody please point out the
error of this code?
begin 644 main.d


M9V%N+BXN(2(I.PT*("`-"B` (`T*"2!3=&%C:R$ *&EN="D ;7E3=&%C:SL-

M8V]U;G0],#L-

M:&EL92 A;7E3=&%C:RYI<T5M<'1Y*"DI>PT*"0EW<FET969L;B B)60B+&UY


M:79A=&4 :6YT(&UA>%-I>F4["2\O<VEZ92!O9B!T:&4 <W1A8VL-" EP<FEV
M871E(%1;72!S=&%C:T%R<F%Y.PT*"7!R:79A=&4 :6YT('1O<#L)"2\O=&]P
M(&]F('1H92!S=&%C:PT*"0T*"0T*"2\O0V]N<W1R=6-T;W(-" ET:&ES*&EN

M97< :6YT6VUA>%-I>F5=.PT*"0ET;W`]+3$["0D)"2\O:6YD:6-A=&5S('1H
M870 ;F\ :71E;7, 87)E(&EN('1H92!S=&%C:PT*"0D-" D)?0T*"0T*"2\O
M4'5S:"!I=&5M<R!T;R!T:&4 <W1A8VL-" EP=6)L:6, =F]I9"!P=7-H*%0 


M"7!U8FQI8R!4('!O<" I>PT*"0ER971U<FX <W1A8VM!<G)A>5MT;W`M+5T[

M('!E96LH*7L-" D)<F5T=7)N('-T86-K07)R87E;=&]P73L-" D)?0T*"0T*

M(&)O;VP :7-%;7!T>2 I>PT*"0EI9BAT;W`]/2TQ*7L-" D)"7)E='5R;B!T
M<G5E.PT*"0D)?0T*"0EE;'-E>PT*"0D)<F5T=7)N(&9A;'-E.PT*"0D)?0T*

M"7!U8FQI8R!B;V]L(&ES1G5L;" I>PT*"0EI9BAT;W`]/6UA>%-I>F4M,2E[

<86QS93L-" D)"7T-" D)?0T*"0T*"7T-" D-" ``
`
end
Mar 24 2011
next sibling parent reply "Simen kjaeraas" <simen.kjaras gmail.com> writes:
On Fri, 25 Mar 2011 06:18:21 +0100, Ishan Thilina <ishanthilina gmail.com>  
wrote:

 Hi,

 I'm still new to D. I tried to implement a stack using templates. But I  
 get an
 "Access Violation" error when I try to run a test on the stack that I  
 made.The
 source code is attached with this mail. Can somebody please point out the
 error of this code?
Line 10:
 	 Stack! (int) myStack;
Stack!(int) is a class, hence you have to initialize it with new. So this line should be:
 	 Stack! (int) myStack = new Stack! (int);
or (perhaps more idiomatic):
 	 auto myStack = new Stack! (int);
-- Simen
Mar 24 2011
parent Ishan Thilina <ishanthilina gmail.com> writes:
 Simen:

Thanks a lot, That solved the problem :).

 Ali:

:s I'm confused, some of the readers has got the attachment correctly :s
Mar 25 2011
prev sibling next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 03/24/2011 10:18 PM, Ishan Thilina wrote:
 Hi,

 I'm still new to D. I tried to implement a stack using templates. But 
I get an
 "Access Violation" error when I try to run a test on the stack that I 
made.The
 source code is attached with this mail. Can somebody please point out the
 error of this code?
I would really love to look at it but like some other people all I get is the following non-D code. ;) I don't know whether the problem is on my end but e-mail and news used to be easier. :) Ali
 begin 644 main.d


[snip]
Mar 24 2011
parent reply "Regan Heath" <regan netmail.co.nz> writes:
On Fri, 25 Mar 2011 05:51:11 -0000, Ali =C7ehreli <acehreli yahoo.com> w=
rote:

 On 03/24/2011 10:18 PM, Ishan Thilina wrote:
  > Hi,
  >
  > I'm still new to D. I tried to implement a stack using templates. B=
ut =
 I get an
  > "Access Violation" error when I try to run a test on the stack that=
I =
 made.The
  > source code is attached with this mail. Can somebody please point o=
ut =
 the
  > error of this code?

 I would really love to look at it but like some other people all I get=
=
 is the following non-D code. ;) I don't know whether the problem is on=
=
 my end but e-mail and news used to be easier. :)

 Ali

  > begin 644 main.d

EN


 [snip]
FYI.. that's uuencoded data: http://en.wikipedia.org/wiki/Uuencoding it's one of the older style encodings used by NNTP. Most readers should= = support it. If you're on unix there may be a program uudecode which can= = decode it for you. R
Mar 25 2011
parent Bekenn <leaveme alone.com> writes:
On 3/25/2011 3:34 AM, Regan Heath wrote:
 FYI.. that's uuencoded data:
 http://en.wikipedia.org/wiki/Uuencoding

 it's one of the older style encodings used by NNTP. Most readers should
 support it.
Oddly enough, Thunderbird is one that doesn't.
Mar 25 2011
prev sibling next sibling parent spir <denis.spir gmail.com> writes:
On 03/25/2011 06:18 AM, Ishan Thilina wrote:
 Hi,

 I'm still new to D. I tried to implement a stack using templates. But I get an
 "Access Violation" error when I try to run a test on the stack that I made.The
 source code is attached with this mail. Can somebody please point out the
 error of this code?
I occasionnally receive such messages from D's mailing list (only):
 begin 644 main.d


 M9V%N+BXN(2(I.PT*("`-"B` (`T*"2!3=&%C:R$ *&EN="D ;7E3=&%C:SL-

 M8V]U;G0],#L-

 M:&EL92 A;7E3=&%C:RYI<T5M<'1Y*"DI>PT*"0EW<FET969L;B B)60B+&UY


 M:79A=&4 :6YT(&UA>%-I>F4["2\O<VEZ92!O9B!T:&4 <W1A8VL-" EP<FEV
 M871E(%1;72!S=&%C:T%R<F%Y.PT*"7!R:79A=&4 :6YT('1O<#L)"2\O=&]P
 M(&]F('1H92!S=&%C:PT*"0T*"0T*"2\O0V]N<W1R=6-T;W(-" ET:&ES*&EN

 M97< :6YT6VUA>%-I>F5=.PT*"0ET;W`]+3$["0D)"2\O:6YD:6-A=&5S('1H
 M870 ;F\ :71E;7, 87)E(&EN('1H92!S=&%C:PT*"0D-" D)?0T*"0T*"2\O
 M4'5S:"!I=&5M<R!T;R!T:&4 <W1A8VL-" EP=6)L:6, =F]I9"!P=7-H*%0 


 M"7!U8FQI8R!4('!O<" I>PT*"0ER971U<FX <W1A8VM!<G)A>5MT;W`M+5T[

 M('!E96LH*7L-" D)<F5T=7)N('-T86-K07)R87E;=&]P73L-" D)?0T*"0T*

 M(&)O;VP :7-%;7!T>2 I>PT*"0EI9BAT;W`]/2TQ*7L-" D)"7)E='5R;B!T
 M<G5E.PT*"0D)?0T*"0EE;'-E>PT*"0D)<F5T=7)N(&9A;'-E.PT*"0D)?0T*

 M"7!U8FQI8R!B;V]L(&ES1G5L;" I>PT*"0EI9BAT;W`]/6UA>%-I>F4M,2E[

 <86QS93L-" D)"7T-" D)?0T*"0T*"7T-" D-" ``
 `
 end
-- _________________ vita es estrany spir.wikidot.com
Mar 25 2011
prev sibling parent Jesse Phillips <jessekphillips+D gmail.com> writes:
Ishan Thilina Wrote:

 Hi,
 
 I'm still new to D. I tried to implement a stack using templates. But I get an
 "Access Violation" error when I try to run a test on the stack that I made.The
 source code is attached with this mail. Can somebody please point out the
 error of this code?
In general I find attaching files to Usenet annoying. Many times it comes in as an encoded file, Web-News is kind enough to let you download the php that generates the page, but not the file. I recommend using a pastbin/gist, this allows the viewing of the file without downloading and usually syntax highlighting. But you have your answer... so next time.
Mar 25 2011