This is a complex subject, and there are no hard-and-fast rules. One is not automatically better than the other, but it is true that CDs are relatively primitive devices, in the sense that they are new and still undergoing development. In theory they are perfect, in reality perhaps not so much. But, they can be improved.
You must be careful to understand that a CD and a vinyl record are not, inherently, different.
You must be able to conceptually understand that they are simply storage media. The storage media is not the data. Not only are they storage media, they are analog storage media. You can, for example, store digital data on an LP record just as you can store it on a CD. There are vinyl records created in the past that do exactly that.
Similarly, there are optical based turntables that read the analog data stored on an LP without physical contact, ie no stylus touches the LP, the data is read by a laser instead.
So, the question might be better put another way: "Is there a digital format that is as accurate as an analog format?"
The answer is that high resolution digital formats do indeed approach and in some ways exceed the analog format for accuracy. A 24-bit format with a high sampling rate, eg 192 Khz, is an example. There is no reason to limit yourself to RedBook CD format of 16 bits and 44.1 Khz sampling frequency.
In this way we can see that you can separate the storage media from the operating method of digital reproduction ... digital does not mean you must limit yourself to CD's RedBook Standard. And it then follows that there may be digital formats that improve upon an analog format. Once you encode data on an analog storage media, like a CD, then you are stuck with that level of resolution. If the audio recording was made at 16/44.1, then you are stuck with that level of resolution as well.
But what if it were recorded at 24/192, and downsampled to CD's 16/44.1? Then the CD is again the same ... no higher resolution can come of it. But you could then use the higher resolution data to create another format disk, say a DVD-A disk.
You could debate as to whether this DVD-A is better, equal, or inferior to the analog record. This is still a debate of analog (record) vs digital (optical disk). The theory of both remains the same, yet the digital version now can be seen in a better light, and may well offer better performance.
So, in the end, if you are going to think about digital theory, and compare it to analog theory, you have to keep in mind that digital theory can improve, so shortcomings you find on a CD can be overcome, with a higher resolution recording method. And from this you can see that it is not correct to dismiss digital as a system. Regardless of how it compares to an analog playback system, you can increase the sampling frequency and resolution until those drawbacks are overcome. Similarly, analog reproduction systems are not fixed either. We can improve upon the cartridge, the phono preamp, and anything in the chain up to the loudspeaker.
With digital or analog, of course, we must keep in mind the performance is analog, and the final reproduction we can hear is analog. It is the stages in between we are concerned with. Broadly speaking, there is always a chance for error when you change the format of something. Because of that, it's possible to introduce new errors that are impossible without the conversion, and often these errors are unanticipated.
An example: an optical cable between two digital components vs a copper-based electrical cable. Both carry a signal that represents the digital data. In the case of the optical cable we must translate the data to an optical version, and back, so it may be used. It is still digital data, but the form of it's transmission has changed.
If there is some problem with the conversion from electrical to optical, we can introduce an error impossible with the copper cable. On the other hand, it must be that there is a different problem with the copper cable we are trying to correct ... otherwise there is no point in the added complexity the conversion introduces.
In the case of an optical cable, we eliminate the possibility of carrying AC line hum on the signal. So, a problem is identified, and a solution offered. We must make sure the solution does not introduce new problems in the attempt to eliminate an old one.
And so it is with an analog vs digital method of storing music. It is my opinion that the use of digital to solve one problem (noise and signal to noise) has introduced a new problem that cannot exist in the analog domain. In this case we chose a sampling frequency and bit depth that is insufficient to completely equal the analog record's accuracy (in my opinion). There are problems with the conversion to digital and back to analog that analog-only will not have to deal with. Such issues must always be addressed by the new method.
I too prefer many analog system to their digital counterparts. But it's important to keep in mind that digital methods are not fixed in stone, and where a limitation is found, an answer may also be found. This is the correct way to think of digital reproduction as a theory and method of encoding, storage and retrieval of music.
I was thinking of this matter by the time i learn how digital sound is generated and works
The idea of sampling rate makes me beleive that cds have less accuracy than the old classic vinil LPs. "
From that we can answer your question directly.
" ... The idea of sampling rate makes me beleive that cds have less accuracy than the old classic vinil LPs. ..." [Note: it is 'vinyl"]
I agree that you are correct here. It must be said that you will find others who do not agree with us. We must be careful that we understand that it it is not "the idea of sampling rate" that is the problem, it is the choice of sampling rate.
" ... In general, i beleive that analog is better thnan digital. Am i wrong? ..."
I believe I have shown that you may well be wrong. But not for CDs; in that case I suggest you are correct.